O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Computing an ROC curve using the titanic dataset

Here is an example of plotting an ROC curve on the titanic dataset, using a simple logistic regression model to predict survival:

install.packages("titanic")install.packages("ROCR")library(titanic)library(ROCR)titanic <- titanic_train[complete.cases(titanic_train), ] model <- glm(as.factor(Survived) ~ Sex+Age+Pclass, data=titanic, family="binomial")    pred <- prediction(predict(model), titanic$Survived)    perf <- performance(pred,"tpr","fpr")    plot(perf)    abline(a=0,b=1)

The AUC curve is plotted along with the various cutoff values for the probability of the predicted outcome. The diagonal reference line represents a random model. The area under the logistic model curve looks to be about 75% of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required