r – Equivalence in kmeans in caret :: train

I tried to mount a model kmeans inside the flat rate caret with the function train. But I noticed that it is not available. I've generated a framework to do this:

set.seed (15)

d <- data.frame (
x = replicate (6, rnorm (10000, 1000, 125))
)

cluster <- kmeans (d, centers = 3)
cluster

d $ group <- as.factor (cluster[['cluster']])

library (recipes)
library (caret)

r <- recipe (group ~., data = d)
p <- prep (r, d)
b <- cook (p, d)

t <- train (
r
d
method = "kmeans",
trControl = trainControl (method = & # 39; cv; number = 3)
)

Error: The kmeans model is not in the built-in caret library

  • Is there a function equivalent to kmeans so that I can do the validation of the model?

I adjusted with a lda and that was fine, but I would like guidance regarding kmeans.