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 lift-area-ratio

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, save=False, file_name="")

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.10
  • numpy>=2.2.0
  • pandas>=2.3.0
  • matplotlib>=3.10.0

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lift_area_ratio-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 de59a0bd0036ffcb7e85510b10a0282762304b099614ce2ca8840099d6db0fc8
MD5 c64a455d80525e895570e2dee1d44e4b
BLAKE2b-256 04221ed34607e30c86db8f79066ecb22becbaffdaef0eca5e4fde2bc8fb40b3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lift_area_ratio-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e17f47254a7b13347cdf6a718ab9b23b92e916cf6023eab2b38fdaf4aa2239d7
MD5 eb8dd95dd3ce7d65a9322bb2359a6512
BLAKE2b-256 e26657af9816551a68bb2f8ec49ccbd6f1d57622f3c0b56afd1abc79b7d34eb3

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