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

Best Online Course : Practical Data Science using R

- Explain Advanced Algorithms in Simple English
- Live Projects & Case Studies
- Domain Knowledge
- Job Placement Assistance
- Money Back Guarantee


R Tutorials : 75 Free R Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has close to 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like retail and commercial banking, Telecom, HR and Automotive.


While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

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

Post a Comment

Next → ← Prev