R : Calculating AUC of training dataset


R Data Science: R Programming A-Z: R For Data Science With Real Exercises!

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
Coursera Data Science

R Tutorials : 75 Free R Tutorials

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