liveBook · Manning

Gini impurity

As explained in Fight Fraud with Machine Learning

Gini impurity is a measure of the class mixture within a decision-tree node, with zero indicating a node containing a single class.

Gini impurity measures how mixed the classes are within a decision-tree node. It is calculated as 1 minus the sum of squared class probabilities. A score of 0 means every transaction belongs to one class; higher scores indicate greater heterogeneity. section 3.4.4 section 3.9

Use the score to read tree nodes and understand their decisions:

  • A node containing equal numbers of genuine and fraudulent transactions has a Gini score of 0.5. section 3.4.4
  • Decision-tree splits aim to reduce Gini impurity, producing nodes with more concentrated class labels. section 3.4.4

Fraud-node calculation

For a node containing nine genuine transactions and one fraudulent transaction, calculate impurity from the two class probabilities using the binary Gini formula. The same approach extends to samples distributed across N classes.

How Fight Fraud with Machine Learning covers it

How deep it goes
Defines binary and multi-class calculation, node interpretation, and impurity-reducing splits.
Examples
Uses genuine and fraudulent transaction counts, transfer-feature splits, and plotted tree nodes as concrete examples.
What you can do after
Evaluate and understand class composition and split behavior when inspecting decision trees and random-forest visualizations.
How it connects
Connects decision trees, random forests, class probabilities, class imbalance, and fraud classification.

Also explained in

Compare how 9 books explain Gini impurity →

Related concepts

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