Hello caret team,
when I use predict.knn3 get error。If I use stats::predict(knn_model,testset[-1],type="prob"),there are no errors. I don't know why。 I want Predictions from k-Nearest Neighbors. Thank you.
main code:
...
trcl=trainControl(method="cv", number =10)
trgrid<-expand.grid(k=seq(1,10,1))
knn_model <- train(label ~ ., data = trainset,method= "knn", trControl = trcl,tuneGrid = trgrid)
pre<-caret::predict(knn_model,testset[-1],type="prob")
Error:
Error: 'predict' is not an exported object from 'namespace:caret'
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Hello caret team, when I use predict.knn3 get error。If I use stats::predict(knn_model,testset[-1],type="prob"),there are no errors. I don't know why。 I want Predictions from k-Nearest Neighbors. Thank you.
main code: ... trcl=trainControl(method="cv", number =10) trgrid<-expand.grid(k=seq(1,10,1)) knn_model <- train(label ~ ., data = trainset,method= "knn", trControl = trcl,tuneGrid = trgrid) pre<-caret::predict(knn_model,testset[-1],type="prob") Error: Error: 'predict' is not an exported object from 'namespace:caret'
R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 [2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 [4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] caret_6.0-92 lattice_0.20-41 ggplot2_3.3.3