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 intracluster or intercluster metrics as measurements. We will now introduce how to compare different clustering methods using cluster.stat
from the fpc
package.
In order to perform a clustering method comparison, one needs to have the previous recipe completed by generating the customer
dataset.
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 objecthc_single
:
> single_c = hclust(dist(customer), method="single") > hc_single = cutree(single_c, k = 4)
- Use hierarchical clustering with the
complete
method to cluster customer data and generate...