Get cluster size in sklearn in python


username

I am using sklearn DBSCAN to cluster data as follows.

#Apply DBSCAN (sims == my data as list of lists)
db1 = DBSCAN(min_samples=1, metric='precomputed').fit(sims)

db1_labels = db1.labels_
db1n_clusters_ = len(set(db1_labels)) - (1 if -1 in db1_labels else 0)
#Returns the number of clusters (E.g., 10 clusters)
print('Estimated number of clusters: %d' % db1n_clusters_)

Now, I want to sort out the top 3 clusters by size (number of data points in each cluster). Please let me know how to get the cluster size in sklearn?

σηγ

Another option is to use numpy.unique:

db1_labels = db1.labels_
labels, counts = np.unique(db1_labels[db1_labels>=0], return_counts=True)
print labels[np.argsort(-counts)[:3]]

Related


Get cluster size in sklearn in python

username I am using sklearn DBSCAN to cluster data as follows. #Apply DBSCAN (sims == my data as list of lists) db1 = DBSCAN(min_samples=1, metric='precomputed').fit(sims) db1_labels = db1.labels_ db1n_clusters_ = len(set(db1_labels)) - (1 if -1 in db1_labels

Get cluster size in sklearn in python

username I am using sklearn DBSCAN to cluster data as follows. #Apply DBSCAN (sims == my data as list of lists) db1 = DBSCAN(min_samples=1, metric='precomputed').fit(sims) db1_labels = db1.labels_ db1n_clusters_ = len(set(db1_labels)) - (1 if -1 in db1_labels

Get cluster size in sklearn in python

username I am using sklearn DBSCAN to cluster data as follows. #Apply DBSCAN (sims == my data as list of lists) db1 = DBSCAN(min_samples=1, metric='precomputed').fit(sims) db1_labels = db1.labels_ db1n_clusters_ = len(set(db1_labels)) - (1 if -1 in db1_labels

Get cluster size in sklearn in python

username I am using sklearn DBSCAN to cluster data as follows. #Apply DBSCAN (sims == my data as list of lists) db1 = DBSCAN(min_samples=1, metric='precomputed').fit(sims) db1_labels = db1.labels_ db1n_clusters_ = len(set(db1_labels)) - (1 if -1 in db1_labels

Labels for cluster centers in Python sklearn

awest1 When using sklearn classes sklearn.clusterfor K-means clustering, the fitted k-means object has 3 properties, including a numpy array of cluster centers named (centers x features) cluster_centers_. However, these centers do not have labels attached. My

Labels for cluster centers in Python sklearn

awest1 When using sklearn classes sklearn.clusterfor K-means clustering, the fitted k-means object has 3 properties including a numpy array of cluster centers named (centers x features) cluster_centers_. However, these centers do not have labels attached. My q

Labels for cluster centers in Python sklearn

awest1 When using sklearn classes sklearn.clusterfor K-means clustering, the fitted k-means object has 3 properties including a numpy array of cluster centers named (centers x features) cluster_centers_. However, these centers do not have labels attached. My q

Labels for cluster centers in Python sklearn

awest1 When using sklearn classes sklearn.clusterfor K-means clustering, the fitted k-means object has 3 properties including a numpy array of cluster centers named (centers x features) cluster_centers_. However, these centers do not have labels attached. My q

Labels for cluster centers in Python sklearn

awest1 When using sklearn classes sklearn.clusterfor K-means clustering, the fitted k-means object has 3 properties, including a numpy array of cluster centers named (centers x features) cluster_centers_. However, these centers do not have labels attached. My

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

Markerclusterer get cluster size in meters

Sushmit Chakraborty I am learning Google Maps in JavaScript. I'm following the tutorial code and so far I have a map with some markers clustered on zoom out. Here is the code - <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.

How to get the size of a pixel cluster in R

Laurent I have a picture in 2 colors. Red pixels are clustered. I would like to know the maximum size of each cluster to compare with an acceptable tolerance. How to do it? Is there a function to execute? Alan Cameron For this kind of image analysis, you can c

Redis - get total dataset size in cluster

pre When the Redis instance is set up and running, the dataset size (in bytes) can be retrieved from the output of the following command by looking at the used_memory_dataset field. ./redis-cli -h <ip address> -p <port> info However, when I have multiple inst

How to get the size of a pixel cluster in R

Laurent I have a picture in 2 colors. Red pixels are clustered. I would like to know the maximum size of each cluster to compare with an acceptable tolerance. How to do it? Is there a function to execute? Alan Cameron For this kind of image analysis, you can c

How to get the size of a pixel cluster in R

Laurent I have a picture in 2 colors. Red pixels are clustered. I would like to know the maximum size of each cluster to compare with an acceptable tolerance. How to do it? Is there a function to execute? Alan Cameron For this kind of image analysis, you can c

How to get the size of a pixel cluster in R

Laurent I have a picture in 2 colors. Red pixels are clustered. I would like to know the maximum size of each cluster to compare with an acceptable tolerance. How to do it? Is there a function to execute? Alan Cameron For this kind of image analysis, you can c

How to get the size of a pixel cluster in R

Laurent I have a picture in 2 colors. Red pixels are clustered. I would like to know the maximum size of each cluster to compare with an acceptable tolerance. How to do it? Is there a function to execute? Alan Cameron For this kind of image analysis, you can c