Description Usage Arguments Value Examples
Choose Initial K-Means Values
1 | kmeans_init(data = NULL, K = NULL, method = "kmeanspp", seed = NULL)
|
data |
the data object (data frame or matrix) that k-means clustering will be applied to. |
K |
the number of initial values to be chosen. Should correspond to the number of clusters to be chosen. |
method |
"kmeanspp" or "rp". The initialisation method specified as a string. "kmeanspp" refers to kmeans++ method and "rp" refers to random points method. More information on kmeans initialization methods can be found here. |
seed |
the seed to be set if "rp" is specified as method. If NULL, no seed will be set. |
A matrix with coordinates for initialization values, where each row is an initialization value and the columns correspond with the columns of the input data object.
1 2 3 4 5 6 7 8 9 10 11 | # create input data object with two distinct clusters
data <- data.frame(x = runif(100, min = 0, max = 10) + rep(c(0, 10), 50), y = rnorm(100, 5, 1) + rep(c(0, 10), 50))
# kmeans++ algorithm by default
kmeans_init(data = data, K = 2)
# random points initialization method
kmeans_init(data = data, K = 2, method = "rp")
# random points initialization method with seed set
kmeans_init(data = data, K = 2, method = "rp", seed = 1234)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.