Previous lesson. Classification Quick Reference Guide
Module 04 Exercise Pack
Classification metrics on a tiny labeled matrix.
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
- Compute accuracy on the fixed y_true / y_pred pair.
- Compute precision for class 1.
- Compute recall for class 1.
- Compute F1 for class 1.
- Build the 2x2 confusion matrix.
- Count false positives from that matrix.
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/04-supervised-learning-classification/exercises/solutions.py").resolve()
sys.path.insert(0, str(p.parent))
runpy.run_path(str(p), run_name="__main__")
print("mod04-exercises-smoke OK")