Description Usage Arguments Value Examples
View source: R/kmeans_cluster_predict.R
predict the label for each new data it belongs
1 | kmeans_cluster_predict(X, center)
|
X |
numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns). |
center |
the centres for each clusters |
label for each row observations
1 2 3 4 5 6 7 8 9 10 11 12 13 | # One dimension example
x = c(1,2,4,6,3)
mu = c(2,4)
kmeans_cluster_predict(x, mu)
# Multi dimension example
X1 <- runif(1000,0,1)
X2 <- runif(1000,0,1)
X3 <- runif(1000,2,3)
X4 <- runif(1000,2,3)
train_data <- cbind(c(X1,X3),c(X2,X4))
# Note the center for each cluster is columnwise
# ensure the number of row of center equal to the number of column of X
kmeans_cluster_predict(train_data , matrix(c(2,2,0,0),2,2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.