liveBook · Manning

Gini impurity

As explained in Machine Learning Algorithms in Depth

The Gini index is an impurity measure for evaluating the heterogeneity of class labels in a set or node.

Gini impurity measures how heterogeneous class labels are within a dataset region or decision-tree node. CART minimizes it when selecting feature thresholds, favoring pure leaves while limiting tree depth to reduce overfitting. section 5.6

Interpret the measure through class proportions:

  • Let πk denote the fraction of points in a region belonging to class k. section 5.6
  • A pure leaf has πk = 1 for its class and Gini impurity zero. section 5.6
  • The measure can be interpreted as the expected error rate of assigning a random point using the region’s class distribution. section 5.6

Choosing a one-dimensional split

For X = [1.5, 1.7, 2.3, 2.7, 2.7] and y = [1, 1, 2, 2, 3], threshold 2 creates a pure left region and a mixed right region with labels [2, 2, 3]. CART compares this weighted impurity with alternatives and selects the minimum-cost split. section 5.6

How Machine Learning Algorithms in Depth covers it

How deep it goes
Explains class proportions, purity, expected error, and a threshold example, while contrasting entropy as an alternative objective.
Examples
Uses a five-point one-dimensional dataset, threshold 2, pure left leaf, and mixed right leaf.
What it assumes
Assumes familiarity with class labels, feature thresholds, probability fractions, and decision-tree leaves.
What you can do after
Evaluate candidate classification splits and implement the surrounding CART search procedure.
How it connects
Connects classification, decision trees, CART, entropy, overfitting, and threshold optimization.

Also explained in

Compare how 5 books explain Gini impurity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.