/W08
实验Lab: A bank campaign, from charter to baseline
- Dataset
- UCI Bank Marketing (45,211 rows, CC BY 4.0)
- Time
- 3 hours
Capstone Due this week: Capstone data report: cleaning, EDA, and a baseline.
This week you'll be able to
- Name the stages of CRISP-DM and say what leaves each stage.
- Spot target leakage and train/serve skew in a feature list.
- Fit and compare linear, tree, and distance-based models against a baseline, inside a pipeline.
Goal
Run the first lap of the lifecycle on a real project. Write a charter, find the leak, build a baseline, and compare three model families fairly.
Data
Phone marketing campaigns by a Portuguese bank. The target, y, is whether the client subscribed to a term deposit. About 11.7% did.
import pandas as pd
bank = pd.read_csv("https://archive.ics.uci.edu/static/public/222/data.csv")
bank["y"].value_counts(normalize=True)Tasks
- Write a one-page project charter (Procedure 10.1). The bank wants to decide whom to call next quarter.
- Read the column descriptions on the dataset page. One column is only known after the call ends. Find it. Explain why it must not be a feature (Procedure 2.5).
- Note how missing values and "never contacted" are coded in
pdays,poutcomeandcontact. Decide how to handle each. - Hold out a stratified test set of 20%. Don't look at it again until task 7.
- Build a
Pipelinewith aColumnTransformer: scale the numeric columns, one-hot the categorical ones. - Compare four models under identical conditions (Procedure 11.2): a dummy baseline that always says "no", logistic regression, a decision tree, and k-nearest neighbours. Use 5-fold stratified CV and report ROC-AUC and recall.
- Score the best model once on the test set. Compare its train and test scores (Procedure 11.4). Is it overfitting?
- Refit the best model with the leaky column included. Report how much the score jumps. That jump is what a leak looks like.
Deliverable
The charter, a results table for task 6, the test score, and a paragraph on the leak.
Done when
- The leaky column is out of every model except task 8.
- All four models use the same pipeline and the same folds.
- The test set is used once.
Capstone
Your capstone data report is due this week. See the capstone brief.