1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Regression with statsmodels in Python

Exercise

Measuring logistic model performance

As you know by now, several metrics exist for measuring the performance of a logistic regression model. In this last exercise, you'll manually calculate accuracy, sensitivity, and specificity. Recall the following definitions:

Accuracy is the proportion of predictions that are correct. $$ \text{accuracy} = \frac{TN + TP}{TN + FN + FP + TP} $$

Sensitivity is the proportion of true observations that are correctly predicted by the model as being true. $$ \text{sensitivity} = \frac{TP}{TP + FN} $$

Specificity is the proportion of false observations that are correctly predicted by the model as being false. $$ \text{specificity} = \frac{TN}{TN + FP} $$

churn, mdl_churn_vs_relationship, and conf_matrix are available.

Instructions

100 XP
  • Extract the number of true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) from conf_matrix.
  • Calculate the accuracy of the model.
  • Calculate the sensitivity of the model.
  • Calculate the specificity of the model.