@@ -89,6 +89,16 @@ fert$output <- as.integer(fert$output)
8989fert.glm <- glm(output ~ . , family = binomial(link = " logit" ), data = fert )
9090summary(fert.glm )
9191
92+
93+ # Prediction using logistic regression model
94+ fert.pred <- predict(fert.glm , type = " response" )
95+ # Score table: gives the values of false positive, false negative, true positive and true negative
96+ # Based on a specific cut off probability: 0.3 means that R should classify all probabilities of less than 0.3 as false and greater than 0.3 as true
97+ score.table(fert.pred ,fert $ output ,0.3 )
98+ # ROC plot: Ratio of true positives to false positives
99+ # Upper right-hand corner is an ideal curve
100+ plot.roc(fert.pred , fert $ output , main = " ROC Curve - Fertility" , col = " blue" )
101+
92102# #####################
93103#
94104# Practice Problems
@@ -117,6 +127,12 @@ summary(fert.glm)
117127
118128# 10. Compare the models using ajd-R2 (won't work for logistic)
119129
120- # 11. Use the first linear regression model and for the logistic regression model to predict test values
130+ # 11. Use the first and second linear regression model to predict test values
121131
122132# 12. Compare these two models using MSE
133+
134+ # 13. Using your logistic regression model construct a confusion matrix
135+
136+ # 14. Using your logistic regression model construct a ROC curve
137+
138+ # 15. Compare the logistic regression model you made with the one we constructed as a class using ROC and confusion matrix
0 commit comments