I am conducting clustering analysis in which I am using three clustering algorithms K-means
, Spectral Clustering
, and Hierarchical clustering
on 3 datasets in UCI repository.
I have used R
packages to conduct clustering analysis and got the results such as Size of clusters, cluster vector, cluster means, Within cluster sum of squares, and grouping of cluster by Class.
Following is an example of my K-means
on the Pima Indian diabetes data in UCI repository:
diabetes <- read.csv(url("http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data"), header = FALSE)
names(diabetes)<- c("No.ofTimesPregnant", "GlucoseConcentration", "BloodPressure", "TricepSkinThickness", "insulin", "BMI", "PedigreeFunction", "Age", "Class")
set.seed(20)
KmeansCluster <- kmeans(diabetes[, 1:8], 4, nstart = 20, iter.max=10)
pcol <- as.character(diabetes$Class)
pairs(diabetes[1:8], pch = pcol, col = c("green", "red") KmeansCluster$cluster])
KmeansCluster
table(KmeansCluster$cluster, diabetes$Class)
I wish to know how I can compare the results of each clustering algorithm? So that I can say that particular clustering algorithm is best for this dataset. More specifically to say, what metric should I choose and how I can get that metric in R
(For example, it would be helpful if you could tell me how to get those metric on my above R
code for K-means
)?.
As I know the diameter of the cluster and average distance of each cluster is used as a measure to compare clustering algorithm in general.