Drawing ROC curve from arbitrary forest classification

I am trying to build a ROC curve of a random forest classification. Plotting works, but I think that I am drawing the wrong data, since the final graph has only one point (accuracy).

This is the code I'm using:

set.seed(55)
data.controls <- cforest_unbiased(ntree=100, mtry=3)
data.rf <- cforest(type ~ ., data = dataset ,controls=data.controls) 
pred <- predict(data.rf, type="response")
preds <- prediction(as.numeric(pred), dataset$type)
    perf <- performance(preds,"tpr","fpr")
    performance(preds,"auc")@y.values
    confusionMatrix(pred, dataset$type)

plot(perf,col='red',lwd=3)
abline(a=0,b=1,lwd=2,lty=2,col="gray")
+3
source share
1 answer

To build a schedule for the receiver, you need to pass a continuous output of the classifier, for example. rear probabilities. That is, you need predict (data.rf, newdata, type = "prob").

predicting with type = "response"already gives you a "hardened" ratio as an output. Thus, your operating point is already implicitly fixed. In this regard, your plot is correct.


: overoptimistic!

+2

Source: https://habr.com/ru/post/1657451/


All Articles