Subject: Issue when computing ROC curve (using pROC package) after training with caret package
Context: Win 7, R version 3.5.1 (2018-07-02)
Bonjour,
J'essai de calculer puis d'afficher de multiple courbes ROC.
En premier lieu, j'entraine plusieurs classifieurs pour les comparer (SVM, rf, KNN, LDA...)
J'utilise train() du package caret puis predict().
Ensuite j'utilise roc() from pROC package.
J'obtiens le message suivant:
"Error in roc.default(fit.rf$pred$obs[selectedIndices], fit.rf$pred$pred[selectedIndices], :
Predictor must be numeric or ordered."
Comment corriger cela ou le contourner?
Merci de votre aide
Hubert
ANNEXE:
Mon code est:
....
set.seed(7)
fit.svm <- train(Tiss~., data=dataset, method="svmRadial", metric=metric, trControl=control)
# Random Forest
set.seed(7)
fit.rf <- train(Tiss~., data=dataset, method="rf", metric=metric, trControl=control)
# summarize accuracy of models
results <- resamples(list(lda=fit.lda, cart=fit.cart, knn=fit.knn, svm=fit.svm, rf=fit.rf))
summary(results)
# compare accuracy of models
dotplot(results)
# summarize Best Model
print(fit.rf)
predictions <- predict(fit.rf, validation,, probability = TRUE,, type="raw")
confusionMatrix(predictions, validation$Tiss)
# Select a parameter setting
#selectedIndices <- fit.svm$pred$C == 0.5
selectedIndices <- fit.rf$pred$mtry == 3
# Plot:
petROC<-roc(fit.rf$pred$obs[selectedIndices],fit.rf$pred$pred[selectedIndices],print.auc = TRUE,
# arguments for ci
ci=TRUE, boot.n=100, ci.alpha=0.9, stratified=FALSE,
# arguments for plot
plot=TRUE, auc.polygon=TRUE, max.auc.polygon=TRUE, grid=TRUE,
print.auc=TRUE, show.thres=TRUE)