📏  Gini Coefficient

Gini Coefficient#

A ranking-quality score linearly tied to AUROC: Gini = 2 x AUROC - 1.

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

What it is#

The Gini coefficient has two lives. In economics (Corrado Gini, 1912) it measures inequality in a distribution such as income, via the Lorenz curve — the cumulative share of income against the cumulative share of population. It is the normalised area between the line of perfect equality and the Lorenz curve:

\[\text{Gini} = \frac{A}{A + B},\]

where \(A\) is the area between the equality line and the Lorenz curve and \(B\) is the area under the Lorenz curve.

In machine learning#

For a binary classifier, Gini measures discriminatory power and is a simple linear rescaling of AUROC:

\[\text{Gini} = 2 \cdot \text{AUROC} - 1.\]

So AUROC 0.5 (random) gives Gini 0, AUROC 1.0 (perfect) gives Gini 1, and an AUROC below 0.5 gives a negative Gini. It carries no information beyond AUROC — the same ranking quality on a stretched scale — but it is the convention in finance.

Why credit risk uses it#

Credit-scoring models (loan default, churn, fraud) usually report Gini rather than AUROC: a higher Gini means the model separates “goods” (non-defaulters) from “bads” (defaulters) better, and regulatory frameworks (Basel II/III) often expect it in model validation. The ML Lorenz curve simply replaces “income” with the predicted score and “population” with cases sorted by that score.

Worked example#

  • Model A: AUROC 0.72 → \(\text{Gini} = 2(0.72) - 1 = 0.44\).

  • Model B: AUROC 0.85 → \(\text{Gini} = 0.70\).

Model B ranks defaulters above non-defaulters far better; a Gini of 0.70 is considered excellent in credit risk.

Rules of thumb and edge cases#

  • Typical bands: 0.20–0.30 weak, 0.40–0.50 useful, 0.60–0.70 strong.

  • 0.80+ is suspicious — usually overfitting or target leakage, not a genuinely great model.

  • A negative Gini means predictions are inverted (worse than random); flipping the score sign fixes it.

In code#

from sklearn.metrics import roc_auc_score

gini = 2 * roc_auc_score(y_true, y_score) - 1

Theme: Classification & Averaging Metrics  ·  All terminology



See also

Source article Adapted (context, re-expressed) in our own words from: Gini Coefficient (insightful-data-lab.com).

Tags: purpose: reference topic: terminology level: intermediate