My research is all about comparing the K-means and DBSCAN(Density-Based Spatial Clustering with Application of Noise) and I used python with the aid of jupyter notebook.

I have 28 variables and 3048 observation each. so I used PCA to reduce high dimensional data.

Principal Component Analysis:

enter image description here

enter image description here

First, I standardized each variable using

from sklearn.preprocessing import StandardScaler

I use this method where it plots the variance against the number of components in this case, I choose 6 which explain 85% of the variance.

Elbow Method for K-means:

enter image description here

I use this method to find the most efficient number of K for our components in our case it is K=3.

K-means result:

enter image description here

enter image description here

enter image description here

enter image description here

It's used to find the most efficient eps parameter for DBSCAN in our case, it's 0.03.

DBSCAN enter image description here

I'm confused about the Homogeneity. since it calculates using the target class and the generated number of K

purity = np.count_nonzero(cluster == count)/np.size(cluster) return purity purities = [] i=0

for index in cluster_labels: cluster = y_truth[y_pred == index] purities.insert(i,clusterEvaluate(cluster))
i +=1

printing the mean of pureness of all cluster print('Homogeneity: K-means')

y_truth is the target class(ground truth)

y_pred is the generated random class in each index of my observation (It depends on the number of K's that elbow method calculate)


If the number of a target class is 4 {0,1,2,3}

and the generated y_pred for each index is 5 {0,1,2,3,4} and also the number of K centroids

Does it affect the Homogeneity?

And I'm also confused about the homogeneity and the pureness of a cluster do you guys have any materials to read about those two?

  • $\begingroup$ I am sorry to say this but both plot show no obvious clustering. Maybe, just maybe, some of the dots in the upper right and upper right corners are outlierish but that's about. The first two component do not appear to encapsulate a clustering but rather an overall tendency in the sample. (which is not a problem per se!) $\endgroup$ – usεr11852 says Reinstate Monic Apr 28 at 21:28

Your Answer

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

Browse other questions tagged or ask your own question.