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.1.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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lift_area_ratio-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d9c6508b8f8ff24371f48b3a845202055c505250693357f943f24f456081b2f9
MD5 539dd1638c9f93d65b1e918cdb576719
BLAKE2b-256 dbad6a1c55c4d24b90043dcb52b24bffc25b0edfce3794f1903e74f5882128f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lift_area_ratio-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1db2a8e3de07e64d2f22d648ae6d5eda8ecf9ac45f3acc4c3df31bd06c7bf8d5
MD5 36c21bfe3a22e1eb37479f50abf83590
BLAKE2b-256 6b460497d7748e9823e544f1294b3e6c60fdfd47ca738d857d585fcf3edb7937

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