A scikit-learn pipeline that picks which of a bank's customers to call about a term deposit, with its leak found and its score earned on rows it never saw.
Download UCI's Bank Marketing data (bank-additional-full.csv: 41,188 calls, and whether each client opened a term deposit) and lock away a stratified 20% test set.
Fit a quick model on every column, then find the leak: duration is the length of the call, known only once it's over, so drop it and fit again.
Build one pipeline that scales the numbers and one-hot encodes the categories, and compare logistic regression with HistGradientBoostingClassifier by five-fold cross-validated ROC AUC.
Tune the better model with RandomizedSearchCV, on the training rows only.
Say a call costs $5 and a new deposit earns $50, let TunedThresholdClassifierCV pick the threshold that makes the most money, and only then score the test set, once.
How you'll know it worksTest ROC AUC of at least 0.78 with duration gone, within 0.02 of your cross-validated score, and more profit on the test rows at your threshold than from calling everyone.
Python, pandas and scikit-learn. The data is a free download from the UCI Machine Learning Repository, and everything runs on a laptop in minutes. Uses lessons 03 to 13.
Project: A marketing model on real bank data
From insideout, Classical Machine Learning: A scikit-learn pipeline that picks which of a bank's customers to call about a term deposit, with its leak found and its score earned on rows it never saw.
Steps:
1. Download UCI's Bank Marketing data (bank-additional-full.csv: 41,188 calls, and whether each client opened a term deposit) and lock away a stratified 20% test set.
2. Fit a quick model on every column, then find the leak: duration is the length of the call, known only once it's over, so drop it and fit again.
3. Build one pipeline that scales the numbers and one-hot encodes the categories, and compare logistic regression with HistGradientBoostingClassifier by five-fold cross-validated ROC AUC.
4. Tune the better model with RandomizedSearchCV, on the training rows only.
5. Say a call costs $5 and a new deposit earns $50, let TunedThresholdClassifierCV pick the threshold that makes the most money, and only then score the test set, once.
How you'll know it works: Test ROC AUC of at least 0.78 with duration gone, within 0.02 of your cross-validated score, and more profit on the test rows at your threshold than from calling everyone.
Runs on: Python, pandas and scikit-learn. The data is a free download from the UCI Machine Learning Repository, and everything runs on a laptop in minutes.
Help me build this on my machine, one step at a time. Ask what I've tried first, give hints before full answers, and check my work against "How you'll know it works".