Recipe
The general classification recipe
Use when: you have a labeled dataset and need to predict a discrete category
Goal: a tuned, honestly evaluated classification model with a documented baseline comparison
Taught in Which algorithm should I use?
Quick recipe
-
1
Write down exactly what one sample is. Write down exactly what the target label means in practice. Note which features are safe, and which count as leakage.
Why: this choice quietly decides the split, the metric, and the imbalance plan. Every later step depends on it.
-
2
Compute the majority-class accuracy first, or fit a plain, untuned logistic regression. Do this before touching anything more complex.
Why: without this step, no later score has an honest reference point.
-
3
Fit a regularized logistic regression, a random forest, and a gradient-boosted model. Run all three through the identical Pipeline and CV setup.
Why: different model families capture different structure. It's rarely obvious ahead of time which one this problem rewards.
-
4
Compare candidates by cross-validated precision, recall, F1, or ROC-AUC. Pick the metric based on the real cost of a false positive versus a false negative. Decide this before seeing any results.
Why: accuracy alone is often misleading under class imbalance. Picking the metric after seeing results is a form of over-tuning.
-
5
Apply random search first, then refine with Bayesian optimization via Optuna. Do both only on the single strongest candidate from the last step.
Why: tuning time is short, and spending it on an already-weaker candidate rarely closes a real gap.
-
6
Check feature importance or SHAP values as a final leakage sanity check. Then save the entire fitted Pipeline, not the bare model alone.
Why: saving only the model risks a preprocessing mismatch at inference time.
Common mistakes
- Skipping the baseline, and reporting a raw accuracy number with nothing to compare it to.
- Sticking with one model family before trying at least one other option.
- Picking the metric after seeing which one flatters the favorite model.