View source: R/KmeansAutoElbow.R
KmeansAutoElbow | R Documentation |
Perform Elbow method and kmeans algorithm for the automatic estimation of the number of clusters and data clustering.
KmeansAutoElbow(
features,
Kmax,
StopCriteria = 0.99,
graph = FALSE,
Elbow = TRUE
)
features |
matrix of raw data (point by line). |
Kmax |
maximum number of clusters. |
StopCriteria |
elbow method cumulative explained variance > criteria to stop K-search. |
graph |
boolean: if TRUE, figures for total of within-class inertia and explained variance are plotted. |
Elbow |
boolean: if TRUE, Elbow method is used for finding the knee point of a curve. |
KmeansAutoElbow return partition and K number of groups according to kmeans clustering and Elbow method
The function returns a list containing:
K |
number of clusters obtained by Elbow method. |
res.kmeans |
results obtained from kmeans algorithm. |
KmeansQuick
dat <- rbind(matrix(rnorm(100, mean = 0, sd = 0.3), ncol = 2),
matrix(rnorm(100, mean = 2, sd = 0.3), ncol = 2),
matrix(rnorm(100, mean = 4, sd = 0.3), ncol = 2))
res <- KmeansAutoElbow(dat, Kmax=20, graph=TRUE)
plot(dat[,1], dat[,2], type = "p", xlab = "x", ylab = "y",
col = res$res.kmeans$cluster, main = "K-means clustering")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.