'"Wrong model type for classification" while using Caret library in R (model with qualitative variable)
I am trying to use k-fold validation to find the better k for kNN. But while I run the following code, it appeared error of "Wrong model type for classification". I had referred to the previous similar question ("Wrong model type for classification" in regression problems in R-Caret) but still can't figure out what is the mistake I made for my code.
The data classes are 11 quantitative, 13 quantitative variables (incl. 1 responding variable named:"classification")
install.packages("caret")
library(caret)
control <- trainControl(method="cv",number = 10)
model <- train(classification ~ .,data = CKD.train, method = "knn", trControl = control)
print(model)
Solution 1:[1]
By quantitative do you mean continuous , and by qualitative do you mean categorical?
Because of the wording, I'm not sure if you're trying to predict a categorical response (classification) or a continuous response (regression).
Can you give an example of your data?
This issue is often solved by converting the data into a data.frame before you try and run train e.g.
CKD.train <- data.frame(CKD.train)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rw2 |
