CAI 1000 · Module 2

Learning from Data — Live Demo

Interactive classroom companion · Darren Broemmer · Lake-Sumter State College

Part 1 — How Machines Learn

The Height Predictor

The model starts with one guess: the population average height of 175 cm. Each "step" it sees a new batch of people, measures its error, and nudges its prediction. Change the learning rate and batch size to see how training behavior changes.

0.20
Current Prediction
175.0 cm
Batch Error
Step
0
People Seen
0
Avg Loss (MAE)
Press "Step" to begin training…
Part 3 — Exploratory Data Analysis

Insurance Dataset Explorer

The same dataset used throughout the lecture (N = 80 representative records). Use these charts to answer: which features most predict insurance charges? What does "correlation" look like visually?

💡 Try this: color by Smoker — watch how the scatter plots split into two clouds. Smoker is the strongest predictor in this dataset, even though it's categorical.

A categorical feature can be the most powerful predictor. The gap here is dramatic.

Non-Smoker
Smoker
What EDA reveals: Before building any model, you can see that smokers pay roughly 3–4× more than non-smokers. Any model that ignores this feature will have high bias (underfitting). EDA prevents you from building blind.
Part 1 — Model Error

MAE vs MSE: Why the Choice of Loss Function Matters

Both metrics measure how wrong our predictions are — but they penalize errors very differently. Use the slider to introduce an outlier and watch what happens to each metric.

(1/n) Σ |ei|

Each error counts by its absolute size. A 10 cm error is exactly 5× as bad as a 2 cm error. All errors get a proportional vote, so large outliers don't dominate.

Use MAE when: errors of all sizes matter roughly equally, or your data has outliers you don't want to over-weight.
(1/n) Σ ei2

Each error is squared before averaging. A 10 cm error contributes 100 — but a 2 cm error only contributes 4. Large errors get disproportionately more weight.

Use MSE when: large errors are especially costly (e.g. medical dosing, structural engineering, financial risk).

Five predictions are made. Four have small, realistic errors. The fifth is the outlier. Slide it from a small error (1 cm) to a large one (20 cm) and watch how MAE and MSE respond.

MAE
MSE
MSE / MAE ratio
Prediction Error (eᵢ) |eᵢ| (MAE contrib.) eᵢ² (MSE contrib.)

The key insight: MSE penalization grows with the error itself. A 10 cm error gets penalized 10× more harshly by MSE than MAE does — not just 10× but 10× as if every cm were also multiplied by the error size.

Error size MAE contribution MSE contribution MSE ÷ MAE
1 cm 1 1
2 cm 2 4
5 cm 5 25
10 cm 10 100 10×
15 cm 15 225 15×
20 cm 20 400 20×
The pattern: For any error of size e, MSE contributes vs MAE's e — so MSE is e times harsher. A 1 cm error: equally punished. A 10 cm error: MSE punishes it 10× harder. A 20 cm error: 20× harder. This is why MSE is said to be sensitive to outliers.
Part 4 — Model Error, Bias & Causation

Plotting Relationships Between Variables

ML models detect correlations — not causes. That distinction matters enormously in production.

Slide the controls to change the dataset. Watch the correlation coefficient change.

Pearson r
Interpretation