freecoding.school100% FREE · NO SIGNUP
Tensor TownISSUE #14 of 120

decision trees · gini · entropy

NeuraVSThe Overfit Ogre
Neura saysDecision trees split data on feature thresholds — interpretable but prone to overfitting.

A tree asks a series of yes/no questions ("age > 30?"), splitting data to maximize purity (measured by Gini or entropy) until leaves are mostly one class. They're highly interpretable (you can read the rules) and handle mixed feature types, but a deep tree memorizes the training data (overfits). Pruning and depth limits help — and ensembles fix it entirely.

Power-ups you unlock

The Overfit Ogre attacks — common mistakes

Boss battleExplain why a deep, unpruned tree overfits.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>age &gt; 30?
  ├ yes → income &gt; 50k? → ...
  └ no  → ...
deep tree → memorizes training data → overfit</pre></body></html>
▶ Open the interactive comic issue
‹ Logistic Regression · Binary ClassifierRandom Forests · Ensemble Of Trees ›