R : Calculating AUC of training dataset

We usually make an error when we calculate AUC of a training dataset in R. We set our training dataset in predict function the same way we define our validation data in the function. It is where we make a mistake.

This is incorrect
rfPred <- predict(tuned, dev, type ="prob")
It is incorrect because we are telling R to consider our training dataset as a new dataset and predict it.

This is correct
rfPred <- predict(tuned, type ="prob")
library(ROCR)
#Storing Model Performance Scores
pred  <-prediction(rfPred[,2], dev[, 1])
# Calculating Area under Curve
perf <- performance(pred,"auc")
auc <- as.numeric(perf@y.values)
auc
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

1 Response to "R : Calculating AUC of training dataset"

Next → ← Prev
Love this Post? Spread the Word!
Share