GithubHelp home page GithubHelp logo

jasonwbw / densitypeakcluster Goto Github PK

View Code? Open in Web Editor NEW
295.0 24.0 120.0 7.74 MB

A cluster framework for 'Clustering by fast search and find of density peaks' in science 2014.

License: MIT License

Python 80.69% MATLAB 19.31%

densitypeakcluster's Introduction

DensityPeakCluster

A cluster framework for 'Clustering by fast search and find of density peaks' in science 2014.

How to Use

Step0: If your data is not the distance between points but the points' vector, write you distance builder in distance like distance_builder_data_iris_flower.py.
Step1: Change the data file in step1_choose_center.py, then run it to choose cluster threshold.
Step2: Change the data file and threshold in step2_cluster.py, then run it.

python distance_builder_data_iris_flower.py
python step1_choose_center.py
python step2_cluster.py

Dependencies

  • NumPy: normal computing
  • Matplotlib: For plotting data to choose threshold
  • Scikit-Learn: use for mds to plot result (the code work with the version 0.14 and 0.18 are tested.)

Reference

License

The MIT License (MIT)

densitypeakcluster's People

Contributors

jasonwbw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

densitypeakcluster's Issues

Error while checking sklearn version

On plot.py line 46 when checking
if float(sklearn_version) > 0.14:
got Error because sklearn_version='0.17.1' and as such can't be converted to float
I suggest changing to
float(sklearn_version[:4]) > 0.14

In plot.py , Error: 'bool' object is not subsciptable

At line no 56

version = versiontuple(sklearn_version)[1] > 14
--->if version[0] > 0 or version[1] > 14:
mds = manifold.MDS(max_iter=200, eps=1e-4, n_init=1,
dissimilarity='precomputed')

It is showing an error:
TypeError: 'bool' object is not subscriptable

plot color limit

Now, the color to choose in plot_utils.py is limit to 7, so we can just plot the cluster size less than 7.

MDS Error

2016-02-23 15:37:22,382 : INFO : PLOT: cluster result, start multi-dimensional scaling
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "D:/Machine-Learning/papers/DensityPeakCluster-master/step2_cluster.py", line 19, in <module>
    plot('./data/data_in_paper/example_distances.dat', 20, 0.1)
  File "D:/Machine-Learning/papers/DensityPeakCluster-master/step2_cluster.py", line 16, in plot
    plot_cluster(dpcluster)
  File "plot.py", line 44, in plot_cluster
    dp_mds = mds.fit_transform(dp)
  File "C:\Python27\lib\site-packages\sklearn\manifold\mds.py", line 395, in fit_transform
    eps=self.eps, random_state=self.random_state)
  File "C:\Python27\lib\site-packages\sklearn\manifold\mds.py", line 242, in smacof
    eps=eps, random_state=random_state)
  File "C:\Python27\lib\site-packages\sklearn\manifold\mds.py", line 73, in _smacof_single
    raise ValueError("similarities must be symmetric")
ValueError: similarities must be symmetric

Run your code,I get this result, I use python 2.7.6.
I find this in mds.py file

if X.shape[0] == X.shape[1] and self.dissimilarity != "precomputed":
            warnings.warn("The MDS API has changed. ``fit`` now constructs an"
                          "dissimilarity matrix from data. To use a custom "
                          "dissimilarity matrix, set "
                          "``dissimilarity=precomputed``.")

so I try replace this

        mds = manifold.MDS(max_iter=200, eps=1e-4, n_init=1,dissimilarity="precomputed")
    #mds = manifold.MDS(max_iter=200, eps=1e-4, n_init=1)

this program can run. But I don't know whether correct !

A serious bug in cluster

A serious bug in cluster.py from line 193 to line 200
First, when assign points to the cluster they belong to, we should start from the points with higher local density.
Second, you don't find the border region for each cluster, nor divide the points into cluster core and cluster halo according to the paper.

Maybe MDS error?

UserWarning: The MDS API has changed.``fit``now constructs an dissimilarity matrix from data. To use a custom dissimilarity matrix, set``dissimilarity='precomputed'``. warnings.warn("The MDS API has changed.``fit``now constructs an" INFO : PLOT: end mds, start plot F:\github_download\Clustering by fast search and find of density peaks\DensityPeakCluster-master\plot_utils.py:22: FutureWarning: comparison toNonewill result in an elementwise object comparison in the future. if style_list != None: Traceback (most recent call last): File "F:/github_download/Clustering by fast search and find of density peaks/DensityPeakCluster-master/step2_cluster.py", line 20, in <module> plot('./data/data_iris_flower/iris.forcluster', 40, 0.80624, auto_select_dc = True) File "F:/github_download/Clustering by fast search and find of density peaks/DensityPeakCluster-master/step2_cluster.py", line 16, in plot plot_cluster(dpcluster) File "F:\github_download\Clustering by fast search and find of density peaks\DensityPeakCluster-master\plot.py", line 45, in plot_cluster plot_scatter_diagram(1, dp_mds[:, 0], dp_mds[:, 1], title='cluster', style_list = cls) File "F:\github_download\Clustering by fast search and find of density peaks\DensityPeakCluster-master\plot_utils.py", line 23, in plot_scatter_diagram assert len(x) == len(style_list) and len(styles) >= len(set(style_list)) AssertionError

When ran the step2.py, I got those problems. I'm not sure whether it's a mds error as @liuguiyangnwpu met.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.