Previous lesson. Model Evaluation & Optimization Quick Reference Guide
Module 05 Exercise Pack
Cross-validation and leakage-aware scaling.
How to run
From this exercises/ folder:
python solutions.py
That loads your implementations (in solutions.py) and runs the asserts in tasks.py.
Work pattern:
- Read each
exercise_N_...docstring intasks.py. - Implement the same function names in
solutions.py(starter solutions are already filled). - Re-run
python solutions.pyuntil you see the module OK line.
Deps: numpy, pandas, and scikit-learn where noted. No dataset downloads.
Tasks
- Report mean stratified CV accuracy for logistic regression.
- Report the std of those CV scores.
- Put StandardScaler inside a Pipeline and CV again (no leakage).
- Show the leaky pattern (scale all rows, then CV) so you can contrast it.
- Count StratifiedKFold folds.
- Compute the train-row fraction for equal k-fold.
- List pipeline step names in order.
Hub smoke (do not edit)
CI runs the fence below from the hub repo root.
import runpy
import sys
from pathlib import Path
p = Path("road-to-machine-learning/05-model-evaluation-optimization/exercises/solutions.py").resolve()
sys.path.insert(0, str(p.parent))
runpy.run_path(str(p), run_name="__main__")
print("mod05-exercises-smoke OK")
Previous lesson. Model Evaluation & Optimization Quick Reference Guide