38. Overfitting and Underfitting in Machine Learning
38.4 Tiny Depth Demo
Why. A short side-by-side demo locks the vocabulary.
What. Compare LinearRegression (usually smoother) vs a very deep tree on a noisy numeric toy — watch train vs test error style thinking. For classification metrics stay with accuracy here for speed.
How.
Mini experiment
- Build a small labelled table with some noise.
- Fit a deep tree and a shallow tree.
- Record train/test accuracy for both.
- Write which setting overfits on your run.
# Reuse the deep vs shallow printout from 38.2
# Add one business sentence after you run it:
# "I will not ship a model that only memorises last month's Mauli Dairy rows."
print("Run 38.2 cells, then write your one-line decision.")
Fictional data
Toy x1/x2 tables are for teaching gaps, not production sensors.