June 2017
Beginner to intermediate
576 pages
15h 22m
English
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 ...