I have been trying this. Model can't give me confusion matrix
fit <- rpart(taste ~ ., data = train,method="class",control = rpart.control(cp = 0.01))
summary(fit)
knn_prediction <- predict(fit, test)
confusionMatrix(knn_prediction, test$taste)
#when i tried the confusion matrix it gives me error : matrix must have equal dimensions
CodePudding user response:
Default argument of type of predict.raprt is prob, which makes knn_prediction of yours matrix.
You should use type = "class" to make confusion matrix with your code.
Try
knn_prediction <- predict(fit, test, type = "class")
