Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

7. Model Validation and Classification

How to judge a model honestly on data it has not seen, how to predict a category rather than a number, and how to turn a model’s probabilities into a decision once every kind of error has a price.

Slides

Present full screen Download the PDF

Click or tap the slide to move forward, its left edge to go back; the arrow keys work too.

Reading

Model Validation and Classification builds a churn model for Qahwa House’s loyalty-app members step by step: why “nobody leaves” is already 78.6% accurate, a logistic regression and its odds ratios, the confusion matrix and the ROC curve, a decision tree that scores 100% on its training data and 71% on new members, cross-validation, and the threshold that more than doubles the profit of a retention campaign.

Lab 7: Customer churn model with scikit-learn

Qahwa House can send a 10-SAR retention voucher to loyalty-app members who look likely to leave. Which members should get one, and how much is the campaign worth? You split the data, overfit a tree on purpose and fix it with cross-validation, fit a logistic regression, then write the campaign’s profit function and choose the threshold that maximises it, not the one that maximises accuracy.

Next week

Time-series forecasting: trend, seasonality, exponential smoothing and forecast errors, and a demand-forecast app in Streamlit.

→ Week 8: Time-Series Forecasting