liveBook · Manning

Weighted average Gini impurity

As explained in Statistics Every Programmer Needs

Weighted average Gini impurity is the observation-count-weighted impurity of the child groups produced by a decision-tree split.

Weighted average Gini impurity measures the total class impurity produced by a decision-tree split. Calculate Gini impurity separately for each child group, then combine the values according to the groups’ observation counts. Prefer the split with the lower weighted impurity when selecting a root or internal node. section 6.3.6

Use the metric to evaluate candidate splits:

  • Partition the data on a categorical feature or numeric threshold. section 6.3.6
  • Count the target classes in each child group and calculate each group’s Gini impurity. section 6.3.6
  • Weight the child impurities by their row counts to obtain one impurity value for the feature or threshold. section 6.3.6

Evaluating a numeric threshold

For TO_GO <= 3.5, the child contains 127 failures and 268 conversions; for TO_GO > 3.5, it contains 156 failures and 67 conversions. These class counts provide the inputs for calculating both child impurities and their row-count-weighted combination.

How Statistics Every Programmer Needs covers it

How deep it goes
Explains separate child calculations and row-count weighting, but does not provide the full displayed equation.
Examples
Uses PLAY_TYPE class counts and the numeric TO_GO <= 3.5 threshold with observed CONVERT counts.
What it assumes
Assumes familiarity with class labels and data splitting while explaining impurity calculations from categorical and numeric examples.
What you can do after
Apply it to calculate and compare candidate decision-tree splits for selecting node conditions.
How it connects
Connects Gini impurity with decision trees, classification outcomes, categorical variables, numeric variables, and root nodes.

Also explained in

Compare how 2 books explain weighted average Gini impurity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.