What predictive analytics is, why every business question about the future is a prediction problem — and a churn model you build yourself before 7:30
By the end of tonight you'll have both the concept and the working code — every objective maps to a cell you run yourself.
Descriptive tells you what happened. Predictive tells you what will happen next — and to whom. Prescriptive decides what to do about it. This course lives in the middle, and feeds the third.
Business question → data → features → model → evaluation → decision → monitoring. You'll learn the loop tonight and repeat it thirteen times, on thirteen datasets, until it's reflex.
The IBM Telco dataset: 7,043 customers, 20 columns, one question — who leaves next month? pandas to load, scikit-learn to fit, a held-out test set to keep you honest.
A model that predicts 'nobody churns' is 73% accurate on this data. Yours must beat that — and you'll learn the first three questions to ask of any accuracy number.
A business question, a dataset, a model — and the judgment to evaluate it.
Introductions, what predictive analytics is, and the semester arc: data and features, regression, classification and decisions, trees and gradient boosting, evaluation and trust, unsupervised learning, forecasting, neural networks and LLM features, and finally shipping a model.
From CRISP-DM to the modern ML loop. The step business people skip is framing: what exactly is being predicted, for whom, how far ahead, and what decision changes if the prediction is right?
7,043 customers of a telecom company. Tenure, contract type, monthly charges, internet service, tech support — and a Churn column that says whether they left last month. Ten minutes of pandas to know it before we model it.
Stretch, coffee, meet a future competition teammate.
Split the data, fit a logistic regression on a handful of features, predict on the customers the model has never seen. Twelve lines of Python, and a probability of churn for every customer.
Our model scores 79% accuracy. The 'nobody churns' model scores 73%. Is 80 good? We open the confusion matrix and discover the model catches only half of the churners — and that a retention offer costs $50 while a lost customer costs $1,500.
The pattern you'll use all semester: load → split → fit → predict → evaluate → decide. Nothing to submit this week: run tonight's notebook end to end and try Exercise 1, so that Session 2 — and Homework #1, which opens there — start from code you have already touched.
Seven minutes, one picture you will never forget. The overfitting explorer, explained by the man with the ukulele.
Notebooks, readings, explorers, and the stories behind the methods.
The notebook we build in class: load the Telco data, explore churn rates by contract, split, fit a logistic regression, and read the confusion matrix. Runs free in your browser — no installation.
Open in ColabDrag the model-complexity slider and watch training error fall while test error turns back up. Add noise, resample the data, and see why a model that fits everything predicts nothing.
Open the explorerThe deck from class: the analytics map, the prediction lifecycle, the Telco data, the twelve-line model, and why accuracy lies. Arrow keys to navigate, F for fullscreen.
Open slidesIBM's sample telecom dataset: 7,043 customers, 20 features, 26.5% churn. Hosted in the course repository so every notebook can load it from a URL with no login.
View the dataAmazon Machine Learning University's interactive essay: drag the model complexity and watch bias and variance trade places. The companion to our Overfitting Explorer, with the math when you want it.
Open the explainerWhy we hold data out, what the three splits are for, and the mistake of tuning on the test set — as a scrollable visual story.
Open the explainerThe free textbook chapter that defines the whole field in 40 pages: what we mean by 'learning', prediction versus inference, the bias–variance trade-off, and why a test set is not optional.
Read Chapter 2 (free PDF)The best-selling practitioner's book, chapter 1: types of learning, the main challenges (bad data, overfitting, underfitting), and testing and validating. All notebooks are free on GitHub.
Open the notebooksNetflix estimates its recommendation system saves over $1 billion a year in reduced churn. The whole business case for predictive analytics in one sentence — and the churn problem you just modeled, at scale.
Read the research pageSeven minutes, one picture you will never forget. Watch before Session 2 if the overfitting explorer felt like magic.
Watch on YouTubeProf. Arslan's earlier notebook on the scikit-learn estimator API — choose a model, set hyperparameters, arrange X and y, fit, predict. If tonight's twelve lines went fast, this is the slow version. Hosted in the course repo — opens in Colab with one click.
Open in ColabThe gentlest complete tour of the classifiers you will meet all semester, each with its decision boundary drawn. Older scikit-learn, timeless ideas; the header explains what has changed.
Open in ColabWhat we covered from Python for Everybody chapters 2 and 3, what you should now be able to do, each idea on the churn problem, and the slides embedded. Lab 0 (the self-checking Python Foundations Check) opens in Session 2.
Explore nowOpen the notebook and build it with us.
A telecom company has 7,043 customers and knows which ones left last month. Build a model that scores every customer's probability of leaving — then judge it honestly against the do-nothing baseline.
Unit: one customer. Target: Churn (Yes/No). Horizon: next month. Decision: who gets a retention offer. Write these four down at the top of the notebook — they're the contract with the business.
Churn rate overall (26.5%), then by contract type, by tenure bucket, by internet service. If a chart shows no signal, no model will find it either.
Hold out 20% with stratify=y. Fit a logistic regression on tenure, monthly charges, and contract type. Predict probabilities for the held-out customers.
Accuracy versus the 73% baseline, then the confusion matrix: how many churners did we catch, how many loyal customers did we bother? Sketch what a $50 offer and a $1,500 lost customer do to the answer.
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, confusion_matrix
url = 'https://raw.githubusercontent.com/harslan/isom-835/master/public/data/telco_churn.csv'
df = pd.read_csv(url)
X = pd.get_dummies(df[['tenure', 'MonthlyCharges', 'Contract']], drop_first=True)
y = (df['Churn'] == 'Yes').astype(int)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, stratify=y, random_state=835)
model = LogisticRegression(max_iter=1000).fit(X_train, y_train)
pred = model.predict(X_test)
print(f'Baseline (nobody churns): {1 - y_test.mean():.1%}')
print(f'Model accuracy: {accuracy_score(y_test, pred):.1%}')
print(confusion_matrix(y_test, pred)) Notice what the split gives you that a spreadsheet cannot: an honest score. The model never saw the 1,409 test customers, so its 79% is a forecast of how it will do on next month's customers — not a memory of last month's. And notice what accuracy hides: the bottom-left cell of that matrix is churners we missed, each one worth $1,500. Session 6 is about that cell.
Predictive analytics sits between describing the past and prescribing the future: descriptive → predictive → prescriptive. A prediction is only valuable when a decision changes because of it.
The loop is always the same: frame → data → features → model → evaluate → decide → monitor. The framing step (unit, target, horizon, decision) is the one business people skip and the one that matters most.
Accuracy lies. Always ask: compared with what baseline, on which held-out data, and at what cost per mistake? A 'nobody churns' model is 73% accurate and worth nothing.
Complete these before next Monday — they are the practice that makes the next session land.
Exam-style questions for the ideas in this session — The Prediction Lifecycle. Every wrong answer names the misconception behind it.
Real data arrives in five tables, three date formats, and a thousand missing values. pandas joins, groupbys, and datetime features on the Olist e-commerce dataset — and how to spot the leak that makes a model look brilliant and ship useless.