We can visualize the clusters created by the method using the plotcluster
function. This function takes the original dataset as well as the elements of the clusters as an input. The output is different clusters with different colors for easy differentiation. The clusters are plotted based on the principal components of the features present in the dataset. The principal components are the combination of the features also called attributes present in the dataset:
# plotting the cluster plotcluster(wdata, fit$cluster) dev.copy(png,filename="scatterPlot.png", width=600, height=875); dev.off ();
The output is as follows:
We can use the clustplot
function to view the plot with better visualization; this function requires the packages cluster
to be loaded to the R environment:
library(cluster) clusplot(wdata, fit$cluster, color=TRUE, shade=TRUE, labels=1, lines=0)
The output is as follows: