Comparing clustering methods
After fitting data into clusters using different clustering methods, you may wish to measure the accuracy of the clustering. In most cases, you can use either intra-cluster or inter-cluster metrics as measurements. We now introduce how to compare different clustering methods using custer.stat
from the fpc
package.
Getting ready
In order to perform the clustering method comparison, you need to have completed the previous recipe by generating the hotel location dataset.
How to do it…
Perform the following steps to compare clustering methods:
- First, install and load the
fpc
package:> install.packages("fpc") > library(fpc)
- You then need to use hierarchical clustering with the single method to cluster customer data and generate the object
hc_single
:> hotel.dist <- dist(hotel[,c('lat', 'lon')] , method="euclidean") > single_c <- hclust(hotel.dist, method="single") > hc_single <- cutree(single_c...