Model Metrics

Marketing Analytics: Predicting Customer Churn in Python

Mark Peterson

Director of Data Science, Infoblox

Imbalanced classes

telco['Churn'].value_counts()
no     2850
yes     483
Name: Churn, dtype: int64
  • Accuracy not a very useful metric
Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 1

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 2

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 3

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 4

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 5

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 6

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 7

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 8

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 9

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 10

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 11

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix Part 12

Marketing Analytics: Predicting Customer Churn in Python

Precision

Metric Formula
Precision True Positives / (True Positives + False Positives)

 

  • A model with high precision indicates:
    • Few false positives ("false alarms")
    • Not many non-churners were classified as churners
Marketing Analytics: Predicting Customer Churn in Python

Recall

Metric Formula
Recall/Sensitivity True Positives / (True Positives + False Negatives)

 

  • A model with high recall indicates that it correctly classified most churners
Marketing Analytics: Predicting Customer Churn in Python

Precision vs. Recall

Marketing Analytics: Predicting Customer Churn in Python

Confusion Matrix in scikit-learn

from sklearn.metrics import confusion_matrix

cm = confusion_matrix(y_test, y_pred)
Marketing Analytics: Predicting Customer Churn in Python

Let's practice!

Marketing Analytics: Predicting Customer Churn in Python

Preparing Video For Download...