Module 7 · Classical ML
Module 7: implement, explain and transfer
Read concepts, then attempt the starter notebook. In a source checkout open notebooks/practice/module07-practice.ipynb. Use the core environment and kernel; the practice checks need NumPy even where the module script does not. Three unfinished functions report not_attempted, not a pass. If a download link does not open, use the offline access route.
Construct squared_distance
Return sum of squared coordinate differences for equal-length vectors. Predict the result on squared_distance([2, 4], [1, 2]), implement it and call m07_squared_distance through the notebook check. Then add a changed case and explain which assumption it tests.
Hint for squared_distance
Square coordinate differences; do not compare signed sums.
Construct select_k
Input pairs [K, validation_silhouette]; maximize score, smallest K breaks ties. Predict the result on select_k([[2, 0.4], [3, 0.5], [4, 0.45]]), implement it and call m07_select_k through the notebook check. Then add a changed case and explain which assumption it tests.
Hint for select_k
Use validation geometry and a declared tie-break, not smallest inertia.
Construct profile
Return string cluster IDs mapped to count and mean of a single original-unit feature. Predict the result on profile([2, 4, 10], [0, 0, 1]), implement it and call m07_profile through the notebook check. Then add a changed case and explain which assumption it tests.
Hint for profile
Describe both support and feature level; IDs have no rank.
Work with the complete study's results
Open cluster_counts.csv and k_comparison.csv from the complete study. What share of the 243 test observations falls in each cluster, and which K did validation silhouette choose? Explain why the larger cluster is not "the normal wines". Compare with the construction feedback afterwards.
Reason beyond the visible checks
Write candidate inertia and silhouette values for K = 2, 3 and 4 for which "smallest inertia" and "highest validation silhouette" select different K. Explain why inertia alone tends to favour the largest K you allow. The checks cannot mark this; compare your reasoning with the construction feedback.
Transfer to an IT decision
Cluster service workload profiles on development data. State why a cluster alone cannot authorize throttling a service. Run the complete module study and verify one claim against its actual artifacts; keep the evidence the study workflow lists.
Evidence and feedback
- M07.1: Distinguish supervised, unsupervised, and reinforcement learning by the information available.
- M07.2: Fit training-only scaling and k-means without quality labels.
- M07.3: Compare predefined cluster counts using a validation geometry criterion.
- M07.4: Describe clusters through counts and original-unit profiles.
- M07.5: Explain why internal scores and observational data do not validate actions or rewards.
Use construction feedback after an attempt and recorded experiment feedback for the full workflow. Follow the shared study workflow for evidence, recovery and optional AI disclosure. Official assessment weights remain with your instructor.
Evidence activity: Interpret cluster evidence
Use test_assignments.csv to recompute each cluster size and reconcile with cluster_counts.csv. Interpret one original-unit feature mean in cluster_profiles.csv. Explain why cluster IDs can change between runs without defining new classes, and why agreement with a class label is not the objective used to choose K.
Follow the four steps in reproduce a result and justify its use. Submit your artifact path, independent calculation, discrepancy or agreement, and bounded use decision in the evidence worksheet. Use your complete reference run; this activity complements the small function checks.
Optional chronological anomaly extension
Use unusual days and review workload to compare a detector with a simple baseline on dated observations. This extension reports flags and distribution context, not verified incident accuracy.