liveBook · Manning

Overfitting

As explained in Grokking AI Algorithms, Second Edition

Overfitting is a condition in which a model matches training data too closely and performs poorly on varied unseen data.

Overfitting happens when a model matches its training data so closely that it struggles with new, slightly different data. A high training score alone is not proof: the warning sign is a gap between strong training performance and poor performance on unseen data. section 8.13 section 8.17

The practice-test trap

Imagine memorizing every answer on a practice test. You might score 100% there but fail when the real exam asks differently worded questions. Underfitting is like not studying at all and failing both tests. A good fit is understanding enough to handle unfamiliar questions. section 8.13

A decision tree can become too specific as it repeatedly splits training examples. Its rules may classify those examples perfectly yet fail when real-world examples differ. Pruning removes branches that are too deep or specific, encouraging more general patterns. section 8.17

Figure 8.26 Underfitting, ideal fit, and overfitting
08_26

Compare the illustrated underfit, ideal-fit, and overfit cases; the goal is not simply to eliminate every training error. section 8.17

Another check is to reserve a validation set that the model never trains on and measure its loss during training. If training loss keeps falling while validation loss rises, the model is beginning to memorize rather than generalize. Early stopping ends training when validation loss stops improving. With a patience of three, training stops after three consecutive evaluations without improvement. section 11.34

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines the condition and gives practical warning signs, pruning, and early-stopping guidance without detailing a pruning implementation.
Examples
Uses a memorized practice test, an overly specific decision tree, and early stopping with patience of three.
What it assumes
Defines overfitting and underfitting through a familiar exam analogy while using training scores and validation loss for practical checks.
What you can do after
Diagnose/debug with it by comparing training and unseen-data performance, then consider pruning or validation-guided early stopping.
How it connects
Connects overfitting to underfitting, generalization, decision trees, pruning, validation sets, and early stopping.

Also explained in

Compare how 24 books explain overfitting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.