2

I have a collection of decimals, with each a value between 0.0 and 1.0.

I would like to "cluster" them by value on two dimensions, so that decimals with near values are grouped together, yet spaced enough so that the graph is visually pleasing.

What libraries in Python can I consider to do this?

Requirements:

  • speed over accuracy
  • preferably free
| improve this question | | | | |
  • I'm putting this on hold because it's asking for a recommendation on where to start on a problem, not for a piece of software. If you can edit your question to ask for a piece of software matching specific requirements, we can reopen it. – Undo Jun 20 '14 at 2:04
  • 2
    I made the question on-topic, by modifying it a lot. – Nicolas Raoul Jun 20 '14 at 5:50
  • Thank You Nicolas – Naveen Mohan Jun 20 '14 at 7:13
  • What are your two dimensions? – Franck Dernoncourt Jul 2 '14 at 17:51
2

You can use the module sklearn.cluster from the Python library scikit-learn (free and open-source).

enter image description here

E.g. if you want to use the k-means algorithm:

import numpy as np
from sklearn.cluster import KMeans
kmeans_model = KMeans(n_clusters=3, random_state=1).fit(X)
labels = kmeans_model.labels_
metrics.silhouette_score(X, labels, metric='euclidean')
| improve this answer | | | | |
  • 1
    Thank you. I am using Spectral Clustering and it seems to serve the purpose very well. – Naveen Mohan Jul 3 '14 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.