I'm trying to run a knn with train()
function with the knn3
method:
model_KNN <- train(Y ~ ., training, method = "knn3", trControl = trainControl(
method = "cv", number = 10, verboseIter = TRUE)
However, it gives me the next error:
Error: Model knn3 is not in caret's built-in library
And I have installed caret package like this (and it works with my other functions too):
install.packages("caret")
library(caret)
And also you can see the method knn3
in train()
function: https://www.rdocumentation.org/packages/caret/versions/4.18/topics/train
And it doesn't work. Why?
It looks like you're looking at an older version of the package documentation (4.18) but are most likely running the latest version (6.0-79).
It appears that knn3
may have been renamed to knn
at some point, although I cannot find evidence of that other than the fact that knn3
is missing and replaced with knn
.
You can run names(getModelInfo())
for a list of the different arguments available for the model
parameter. There is also a list of models found here.