Skip to main content

Lift Area Ratio — a population-independent model discrimination metric

Project description

LAR — Lift Area Ratio

A population-independent metric for binary classification model discrimination, designed as a more interpretable alternative to ROC-AUC.


Why not just use AUC?

AUC averages performance across all thresholds equally — including thresholds you'll never use in production. Two models can have the same AUC but behave very differently at your actual operating point.

LAR answers a more practical question:

"How much better than random is my model at concentrating positives at the top of the ranking?"

And unlike AUC, LAR is population independent — it gives comparable scores across datasets with different event rates.


How it works

LAR is based on the Event Rate Ratio (ERR) — at a given percentile, how much more concentrated are positives compared to the overall population:

$$ERR = \frac{b/n}{B/N}$$

Where:

  • N = total observations, B = total positives
  • n = observations up to percentile, b = positives found up to percentile

Plotting ERR across all percentiles gives three reference curves:

  • 🔵 Oracle — perfect model, all positives ranked first. ERR starts at N/B and drops sharply once all positives are found
  • Your model — sits between oracle and random
  • 🔴 Random — flat line at ERR = 1, no discrimination

LAR is the ratio of the areas above the random line:

$$LAR = \frac{A}{O} = \frac{\text{area under model curve}}{\text{area under oracle curve}}$$

LAR value Meaning
0 model has no skill (= random)
1 perfect model (= oracle)
0.83 model captures 83% of perfect discrimination

Since both areas are scaled by the same oracle, the population event rate cancels out — making LAR directly comparable across different datasets and models.


Installation

pip install lar

Or install from source:

git clone https://github.com/yourname/lar.git
cd lar
pip install -e .

Quick start

import numpy as np
from lar import LiftAreaRatio

# your model scores and true labels
scores = model.predict_proba(X)[:, 1]
y = df["default_flag"]

# compute LAR
lar = LiftAreaRatio(n_percentiles=100)
result = lar.fit(scores, y)

# print summary
lar.summary(result)
# =============================================
#   Lift Area Ratio — Summary
# =============================================
#   N (observations) : 2000
#   B (positives)    : 197
#   Event rate (ER)  : 9.85%
#   Max ERR (oracle) : 10.15
# ---------------------------------------------
#   Area model       : 192.66
#   Area oracle      : 231.72
#   LAR  = A / O     : 0.8314
# ---------------------------------------------
#   Interpretation   : model achieves 83.1% of perfect discrimination
# =============================================

# plot lift curves
lar.plot(result, title="My Model")

API

LiftAreaRatio(n_percentiles=100)

Parameter Type Default Description
n_percentiles int 100 number of quantile bins

.fit(scores, y) → LARResult

Parameter Type Description
scores array-like model risk scores (higher = more likely positive)
y array-like binary labels (1 = positive, 0 = negative)

.summary(result)

Prints a formatted summary of the LAR result.

.plot(result, title, figsize)

Plots oracle, model and random lift curves with shaded areas A and O.

LARResult fields

Field Description
lar final LAR score
area_model area under model lift curve
area_oracle area under oracle lift curve
N total observations
B total positives
event_rate B / N
lift_model DataFrame with percentile and ERR per bin
lift_oracle DataFrame with percentile and ERR for oracle

Requirements

  • Python >= 3.8
  • numpy
  • pandas
  • matplotlib

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lift_area_ratio-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lift_area_ratio-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file lift_area_ratio-0.1.0.tar.gz.

File metadata

  • Download URL: lift_area_ratio-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for lift_area_ratio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d60b2ae3976e9805f489c4e5c0ac41cc4a9f4cc2065f154b29ea44163c9f2271
MD5 97c44cbf3ffeab136d5a46de713f0c16
BLAKE2b-256 58330e5c5d9f57c916acbcb79729d5ec36028d955f4f05526af5f5024e3c5882

See more details on using hashes here.

File details

Details for the file lift_area_ratio-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lift_area_ratio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec586a4fbba949c643620412c61b9deb78de092a477bb7ead03868aa7db4e885
MD5 b53fa4a5698abdd3eb9d083687e9f013
BLAKE2b-256 9413d42e74bff629a136b9ad80628c7a75bf977436faad57e458236fbcda7fb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page