R: curve curve graph xgboost

To plot a curve:

library(ROCR)
<data cleaning/scrubbing>
<train data>
.....
.....
rf.perf = performance(rf.prediction, "tpr", "fpr") #for RF
logit.perf = performance (logit.prediction, "tpr", "fpr") #for logistic reg
tree.perf = performance(tree.prediction, "tpr", "fpr") #for cart tree
...
plot(re.perf) #a RF roc curve

If I want to start the classification xgboostand subsequent construction of roc: object = "binary: logistics"

I got confused with the xgboost "auc" argument metrics (page 9 of the CRAN Guide ), it talks about scope. How to build a curve with tpr and fpr to compare models?

I tried searching on the web and github, most of the emphasis on the graph of the importance of the function (for xgboost).

thanks

+4
source share
1 answer

Let me talk about the ROC curve first

ROC (TPR) (FPR) .

python :

from sklearn import metrics
def buildROC(target_test,test_preds):
    fpr, tpr, threshold = metrics.roc_curve(target_test, test_preds)
    roc_auc = metrics.auc(fpr, tpr)
    plt.title('Receiver Operating Characteristic')
    plt.plot(fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc)
    plt.legend(loc = 'lower right')
    plt.plot([0, 1], [0, 1],'r--')
    plt.ylabel('True Positive Rate')
    plt.xlabel('False Positive Rate')
    plt.gcf().savefig('roc.png')

, , 0.2, 0,96 - 0,97

ROC

+1

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


All Articles