nk | R Documentation |
Choose best K (number of clusters)
nk(data, k)
data |
input data (a matrix or data frame) |
k |
a vector of candidate number of clusters |
This function calculate the silhouette scores of each K (number of clusters).
The output object can be used to choose the best K (via summary()
or autoplot()
methods)
a silinfo
object, which contains 'data' (original data), 'silinfo' (silhouette scores), and k (the input k vector)
Guangchuang Yu
x <- nk(iris[,-5], 2:8)
summary(x)
# to visualize the average silhouete score (y axis) with k (x axis)
autoplot(x)
# to visualize a PCA plot color by the choosing k
autoplot(x, k=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.