我可以在K-NN模型训练中强制使用所有K值吗?

时间:2019-05-01 00:48:57

标签: classification knn

我使用此代码来训练用于4-NN和5-NN的K-NN模型:

trainParameters <- trainControl(method = "repeatedcv", number = 10, 
                           repeats = 1, classProbs =  TRUE)
knnModel <- train(Class ~., 
                 data = trainingSet, 
                 method = "knn",
                 tuneGrid   = expand.grid(k = c(4,5)),
                 preProcess = c("center","scale"),
                 trControl = trainParameters)

但是当我执行这一行时:

knnModel 

我得到了模型信息,在其中得到了以下消息:

Accuracy was used to select the optimal model using the largest value.
The final value used for the model was k = 5

然后,所有结果(混淆矩阵,指标等)仅与k = 5模型相关。我想让所有模型都包含在c(...)中。我怎样才能得到它们?

0 个答案:

没有答案