-
Book Overview & Buying
-
Table Of Contents
R Data Science Essentials
By :
After getting to know the ideal number of clusters, we can construct the required number of clusters in the dataset using the K-means method. We use the kmeans function to construct the clusters; this function takes the dataset as well as the number of clusters to be formed as an input. In the following case, we are just passing the number of clusters we want as an output from the pamk function:
fit<- kmeans(wdata, n) table(fit$cluster) 1 2 3 4 5 3 3 27 7 22
As per the preceding output, there are five clusters with varying number of elements in each of the clusters. Even if an isolated element is not found similar to any of the existing clusters, it will be made to form a new cluster. We can see the mean of the elements in the clusters using the aggregate function. As we have to choose the mean to be the aggregation factor for all the attributes in the dataset, we get the mean for each of the clusters formed. If the clusters are mutually exclusive,...
Change the font size
Change margin width
Change background colour