Module 6 · Classical ML

Module 6: Classification and decision trees

Read the overview and learning outcomes here, then follow the learning route. Return to this page’s run instructions for the complete study.

Classify a declared human-rating threshold from real chemistry measurements, then explain the mistakes and decision threshold.

This module works independently: no earlier notebook state, Canvas assignment, paid AI account, or GPU is required. Allow approximately 90–150 minutes plus practice. Small CPU runs demonstrate mechanisms, not production readiness.

Learning outcomes

Learning sequence for this module

Follow foundation → applied concepts → guided construction → independent practice → practice feedback → the complete reference workflow below. If experienced, attempt practice first and use feedback to locate gaps.

The practice sandbox uses development data and its own declared bounds. The full reference retains its model-selection, final-evaluation and artifact contract.

Entry support and topics

Use the foundation bridge if these concepts are new. Basic Python/functions/files and the train/validation/test distinction are assumed with support from Module 2 and Module 5.

A probability estimate is not automatically calibrated confidence. A threshold converts a score into a decision. False positives and false negatives can have different costs; balanced accuracy gives equal weight to recall in each class, not to operational cost.

Real data and its limits

UCI Wine Quality; real red-wine chemistry and human ratings. See the central source register for citation, rights, archive hash, and limitations.

Sources, licenses, hashes, and model provenance distinguish external records from original teaching code. No generated dataset or invented labels are used in this module. Public files still require responsible handling. Source versions are fixed after verified acquisition; changed cached/upstream bytes cause an error. The first data/model download requires internet; retain the cache for offline replay.

The complete workflow

The target is quality score at least seven, a classroom choice. Identical chemistry profiles are kept within one seeded group split. A dummy, logistic regression, and depth-2/4/8 trees are fitted on training; validation chooses a model and threshold from 0.3, 0.5, 0.7. Final labels never choose them. A shallow tree is exported as readable rules even when another method wins.

Run and inspect

Download the complete source or use a checkout. Work from its ml_ai_it folder. Use the core environment instructions and install the regression extra. In commands below, python means your environment executable; use its full path if not activated. If a download link does not open, use the offline access route.

python examples/wine-classification/scripts/run.py --output runs/module06

Use a fresh output directory for a new run; completed studies are not silently overwritten. Open runs/module06/index.html or read summary.txt/summary.json and the companion CSV tables. Read the verified worked report without installing an execution interface.

Key artifacts:

The shared implementation is under src/practical_ml_ai; scripts and commented notebook call the same functions. Keep the notebook inside the complete source tree. Named results and captioned/scoped tables support interpretation without a chart or screenshot. For interface choices and test coverage, see the accessibility guide.

Read selectively

Practice and continue

Complete original practice, then compare worked feedback. Instructor notes map evidence and explain adaptation.

Next: Module 7.

Build understanding step by step

Use the guided construction and mastery check before the full study. New programmers should start with Python Foundation and readiness; use the glossary for notation.

Optional project connection

Extend model comparison with the optional grouped tuning investigation and complete capstone exemplar. These are separate experiments; this module remains independently runnable.