Machine Learning, FoundationsLesson 54 of 92

Module 6 · Trees, ensembles, and the algorithms that win on tables

How a tree chooses where to cut

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 2 of 10 in this chapter

This chapter’s goalChoose between a linear model, a random forest and a gradient boosting library for a given tabular problem and defend the choice, tune the four hyperparameters that actually matter in each, and explain why impurity-based feature importance is biased and what permutation importance and SHAP replace it with.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:59Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

Twenty loans

Twenty applications, six of which defaulted. The tree has to pick one feature and one threshold to split on. How does it decide?

It tries every threshold on every feature and scores each one by how much purer the two resulting groups are than the parent.

Impurity, measured

Gini impurity for a node is 1 - sum of p_k^2 over the classes. It is the probability that two items drawn at random from the node have different labels.

The parent: 6 defaults in 20, so p = 0.3.

Text
Gini(parent) = 1 - (0.3^2 + 0.7^2) = 1 - (0.09 + 0.49) = 0.42

Now try the split income < 300000. It sends 8 rows left, of which 5 defaulted, and 12 right, of which 1 defaulted.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘How a tree chooses where to cut’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/how-a-tree-chooses-a-split (Accessed: 29 November 2026).