The concept
Two students prepare for an exam:
- Student 1 memorizes last years answers word for word.
- Student 2 learns why the answers are right.
On last years questions, both score 100%. On this years new questions, Student 1 falls apart. Thats overfitting.
An overfit model fits its training data too closely, including noise and coincidences, so it fails on new data. The opposite problem, underfitting, is a model too simple to learn even the real pattern.
Walkthrough: forecasting a cafés daily coffee sales
A café has 60 days of sales data. Features: day of week, temperature, rain, local events.
Simple model: learns a few broad rules.
- Weekends sell more, cold days sell more, rain sells less.
- On the 60 training days: typically off by about 20 cups.
- On the next 30 new days: still off by about 20 cups. Consistent.
Overly complex model: learns hundreds of tiny rules.
- It notices that one rainy 14°C Tuesday, with a marathon in town, sold 410 cups, and builds a rule just for that day.
- On the 60 training days: off by about 2 cups. Looks amazing.
- On the next 30 new days: off by about 70 cups. Worse than the simple model.
It memorized one-off events instead of learning what drives sales.
How to catch it
Always hold some data back.
- Train on part of the data (say 80%).
- Test on the 20% the model never saw.
- Great training scores but much worse test scores? Youre overfitting.
How to fix it
- More data, so coincidences wash out.
- A simpler model, or fewer features.
- Stop training earlier, before it starts memorizing.
- Regularization: a penalty that discourages overly complex rules.
Where you see it at work
- Banking: a credit model that looks perfect on last years customers but stumbles when the economy shifts.
- Retail: a demand forecast that learned one viral week and keeps expecting it again.
- Business analysis: a trend line that fits 10 data points perfectly tells you less than you think.
In one sentence
Overfitting is when a model memorizes its training data instead of learning the pattern, so it looks great in practice and fails on anything new.
