AIExplainer
Machine Learning Mathematics Intermediate 2 min read

What is gini impurity?

A measure of the diversity or uncertainty in a dataset

Gini impurity is a statistical measure used to evaluate the purity of a dataset. It calculates the probability that a randomly chosen element from the dataset will be incorrectly classified if it were randomly labeled according to the class distribution of the parent node.

Imagine you have a jar of colored marbles, and you want to know how mixed up the colors are. Gini impurity is like a score that tells you how likely you are to pick a marble of the wrong color if you reached in and grabbed one at random.

A company might use gini impurity to analyze customer data and determine the best way to segment their market based on demographic characteristics.

Gini impurity is used in decision trees and random forests to determine the best split for a node, with the goal of minimizing the impurity of the child nodes.

One common misconception is that gini impurity is a measure of the accuracy of a model, when in fact it is a measure of the diversity of the data.

The concept of gini impurity was first introduced by Corrado Gini in 1912 as a measure of income inequality, and was later adopted in the field of machine learning.

gini coefficient gini index

Three products for different needs — explore what’s relevant to you.