Part 3 · Article 2 Stage 1 · Foundations

ASKING YES-OR-NO QUESTIONS

Decision trees, random forests, and boosted trees—how playing a smart game of '20 Questions' became the undisputed king of spreadsheet AI.

About 13–15 minutes

01

The Game of 20 Questions, Automated

Think about how an experienced emergency-room doctor evaluates a patient with sudden chest pain. She doesn't multiply 40 decimal weights together in her head like a linear regression equation. Instead, she plays a rapid, structured game of yes-or-no questions: "Is the ECG showing ST-elevation? If YES, rush to the cath lab immediately. If NO, is the blood troponin elevated? If YES, admit for cardiac monitoring. If NO, is the pain reproduced when pressing on the rib cage?"

That exact branching flowchart is a Decision Tree—one of the most intuitive algorithms in all of machine learning [1]. Unlike a rigid hand-written rulebook from the 1980s, a machine-learning decision tree doesn't ask a human to guess which questions to ask or where to set the cutoffs. Instead, it scans thousands of past examples and discovers the sharpest yes-or-no splits automatically.

And when you combine hundreds of decision trees into a team—called a Random Forest or Gradient Boosted Trees—you get the undisputed champion of structured tabular data, regularly beating giant deep neural networks on hospital records, financial spreadsheets, and business tables [2].

ZappyWait—how does a computer decide which yes-or-no question to ask FIRST at the top of the tree?

Prof. BoltJust like in 20 Questions! Asking "Does it breathe?" splits the world cleanly in half; asking "Is it a purple flamingo?" wastes a turn. The algorithm picks whichever single question makes the resulting two piles as pure and neat as possible.

02

How a Tree Grows: Chasing Pure Buckets (Gini & Entropy)

Imagine a basket holding 100 patients—50 who developed a post-surgical wound infection and 50 who healed cleanly. Right now, the basket is a 50/50 mess (maximum impurity). The decision tree tries out every possible yes-or-no split across every column in your spreadsheet:

  • Try splitting on "Is the patient left-handed?" Left pile: 25 infected / 25 healthy. Right pile: 25 infected / 25 healthy. Zero improvement—throw that question away!
  • Try splitting on "Is HbA1c (blood sugar) above 8.0%?" Above 8.0%: 38 infected / 7 healthy. Below 8.0%: 12 infected / 43 healthy. Huge jump in purity!

The algorithm measures purity using simple math scores called Gini Impurity or Information Gain (Entropy) and locks in the single best question as the Root Node at the top of the tree. Then it repeats the exact same trick inside the left branch and the right branch—splitting again on smoking status, surgery duration, or steroid use—until each final bucket (called a Leaf) is mostly one clean answer.

Why do clinicians love single decision trees? Two reasons: first, they naturally handle tricky non-linear U-shapes and "IF A AND B together" interactions that break straight-line regression. Second, you can print the whole tree on a clinic wall poster and trace any patient's path with your finger in five seconds!

How a Decision Tree Routes a Clinical Case
Root: Blood Sugar > 8.0%? Branch: Surgery > 2 hrs? Branch: Smoker? Leaf: High Infection Risk (84%)
THE PROBLEM WITH ONE TREE—AND THE MAGIC OF A FORESTWhy one lone tree overfits easily, and how crowds of trees became unstoppable
03

Why One Tree Is Shaky (And How Random Forests Fix It)

Single decision trees have one notorious weakness: they are twitchy and love to overfit. If you let a tree keep asking questions down to 20 levels deep, it will eventually carve out ridiculous hyper-specific leaves like "Age = 57 AND born on a Tuesday AND weight = 73.4 kg → Infected"—memorizing individual training patients by heart! Worse, if you remove just 5% of your training rows and regrow the tree, the entire top-to-bottom flowchart can flip into a totally different shape.

In 2001, statistician Leo Breiman unveiled a brilliant cure called the Random Forest [3]. Instead of trusting one lone, twitchy tree, grow 500 different trees and let them vote! To make sure all 500 trees don't just become identical clones making the exact same mistakes, Breiman added two deliberate doses of randomness:

  1. Random Data Slices (Bagging): Each tree only sees a random reshuffled sample of the patients—so Tree #1 might miss a weird outlier that Tree #2 sees.
  2. Random Clue Subsets: At every split, each tree is only allowed to pick from a random handful of columns (say, 4 clues out of 20). That forces different trees to discover diverse backup patterns instead of everyone staring only at the single loudest clue.

When a brand-new patient arrives, all 500 trees run their own flowcharts and cast a vote. If 410 trees vote "High Risk" and 90 vote "Low Risk," the forest outputs a steady, calm 82% probability. Individual tree quirks cancel out, while true underlying medical patterns shine through.

Random Forest (Parallel Committee)

Builds 500 independent trees side-by-side at the same time and averages their votes. Very hard to break, needs minimal tuning, and resists noisy outliers gracefully.

Gradient Boosted Trees (Relay Team)

Builds trees one after another (XGBoost, LightGBM). Tree #1 makes rough guesses; Tree #2 studies only Tree #1's mistakes; Tree #3 fixes the leftovers—squeezing out world-class accuracy [4].

04

Gradient Boosting (XGBoost): The Secret Weapon Behind Modern Tabular AI

While generative chatbots steal the headlines, ask any working data scientist in healthcare, banking, or logistics what algorithm actually wins competitions on structured spreadsheets—and 9 times out of 10 they will say Gradient Boosted Decision Trees (especially tools named XGBoost and LightGBM).

Think of Random Forest like asking 500 independent doctors for a first opinion and taking the majority vote. Think of Gradient Boosting like a specialized relay team: Doctor #1 examines the patient and makes an initial estimate. Doctor #2 ignores everything Doctor #1 got right and focuses exclusively on fixing the subtle errors left behind. Doctor #3 fixes the tiny leftover errors from Doctors #1 and #2—continuing for hundreds of small, careful corrections.

In hospitals, boosted trees excel at predicting 30-day ICU readmissions, flagging early kidney injury from rolling lab panels, and estimating surgical blood-transfusion needs—handling missing lab values natively without crashing. The one trade-off? You lose the simple one-page poster of a single tree—though modern explainability tools (like SHAP values) can still show exactly how much each clue pushed a patient's score up or down [5].

Tree MethodHow It WorksInterpretabilityAccuracy on TablesBest Use Case
Single Decision TreeOne branching flowchartCrystal clear (1-page poster)Moderate; overfits easilyQuick bedside triage rules
Random Forest500 independent trees votingMedium (feature importance)High & very stableDependable out-of-the-box risk models
Gradient Boosting (XGBoost)Sequential error-fixing relayMedium (needs SHAP values)Top-tier on spreadsheetsICU early warnings, readmission, finance
Decision trees are terrible at extrapolating outside their past range! Because a tree only outputs averages of past buckets, if housing prices or lab values surge higher than anything in its training history, a tree will stay flat at its old maximum instead of projecting upward like linear regression.
A single decision tree mimics human yes-or-no clinical checklists; combining hundreds of trees into Random Forests or Gradient Boosted Trees creates the strongest, most dependable toolkit for structured tabular data.
05

Pruning the Tree: Why Stopping Early Beats Growing a Jungle

Left completely unsupervised, a decision tree is an obsessive perfectionist—it will keep asking yes-or-no questions until every single training patient sits alone in their own private leaf! That produces 100% training accuracy and miserable real-world test performance.

To keep trees sharp and generalizable, engineers act like skilled bonsai gardeners using three simple trimmers:

  • Maximum Depth (Max Layers): Limit the tree to at most 4 or 5 questions deep. If a pattern requires 18 consecutive yes/no splits to describe, it is almost certainly memorized noise.
  • Minimum Leaf Size: Forbid the tree from creating any final bucket holding fewer than, say, 25 patients. Every clinical rule must be backed by a real crowd, never two fluke cases.
  • Cost-Complexity Pruning: Grow the tree out, then snip off any bottom branches that barely improve validation accuracy—leaving a tidy, sturdy flowchart that survives brand-new hospitals.

In fact, famous bedside clinical rules—like the Ottawa Ankle Rules (deciding whether a twisted ankle truly needs an X-ray) or the PECARN Pediatric Head Injury Tree (deciding whether a child with a head bump needs a CT scan)—follow the exact same pruned decision-tree philosophy: 3 to 5 crisp, high-impact questions that spare thousands of patients unnecessary radiation every year.

Feature Importance (Which Clue Mattered Most?)

Random Forests and XGBoost automatically rank every column by how much purity it added across all 500 trees—instantly showing a hospital team that "creatinine trend" mattered 5x more than "resting heart rate."

SHAP Explanations (Why THIS Patient?)

Global importance tells you what matters on average; SHAP values zoom into a single patient—showing "+18% risk from rising lactate, +9% from fever, -6% from normal oxygen"—bringing human readability back to powerful forests.

06

When Trees Beat Deep Learning—And When They Lose

Understanding where tree ensembles shine versus where deep neural networks take over saves huge amounts of time and money:

Trees Win Easily On: Messy real-world spreadsheets with mixed data types (age in years, yes/no flags, lab numbers, missing cells, and sharp clinical cutoffs like "fever > 38.5°C"). On 10,000-row hospital registries, XGBoost trains in two seconds on a laptop, needs zero feature scaling, and routinely beats giant neural networks.

Deep Learning Wins Easily On: Raw unstructured worlds—photographs, chest X-rays, pathology slides, spoken audio, and free-text medical notes—where asking "Is pixel #42,819 brighter than 128?" makes zero sense on its own.

ZappySo if my data lives in neat rows and columns, try Regression first and XGBoost/Random Forest second—and save Deep Learning for images, audio, and language?

Prof. BoltThat single rule of thumb puts you ahead of 90% of people chasing AI hype! Match the tool to the shape of your data, and you'll build faster, safer systems every time.

The evidence file

Checked December 2026. Source types are labelled. Dialogue is fictional.

  1. An Introduction to Statistical Learning (Chapter 8: Tree-Based Methods), Springer, 2nd Ed. 2021; clear introduction to CART decision trees, bagging, random forests, and boosting.
  2. Why do tree-based models still outperform deep learning on tabular data?, NeurIPS Datasets & Benchmarks (Grinsztajn et al.), 2022; empirical proof that boosted trees beat neural networks on typical medium-sized tables.
  3. Random Forests (Leo Breiman), Machine Learning Journal, 2001; foundational paper introducing bagged trees with random feature selection.
  4. XGBoost: A Scalable Tree Boosting System, ACM KDD (Chen & Guestrin), 2016; architecture behind modern gradient boosted decision trees.
  5. A Unified Approach to Interpreting Model Predictions (SHAP), NeurIPS (Lundberg & Lee), 2017; explaining individual patient predictions from tree ensembles.
Write to ussrini.present@gmail.com
Read more: srinipresents.com