I need to plot a ROC curve in R, but I do not know how to correct it.
cctrl2 <- trainControl(method = "cv", number = 10, classProbs = TRUE, savePredictions = TRUE)
modelNb <- train(Treino[, -5], Treino$TOTAL_PEDIDO,
method = "nb",
trControl = cctrl2)
test_class_pred_nb_probs <- predict(modelNb, Teste[, -5], type = "prob")
roc_nb = plot.roc(Teste[, 2],test_class_pred_nb_probs$alto, col='red')
But the test table $ TOTAL_PEDIDO has 4 values (high, regular, low and min) and to plot the ROC curve the value must be atomic. So I did the following.
aux<-Teste[which(Teste$TOTAL_PEDIDO == "alto"),]
test_class_pred_nb_probs <- predict(modelNb, aux[, -5], type = "prob")
roc_nb = plot.roc(aux[, 2],test_class_pred_nb_probs$alto, col='red')
And the message appears:
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?