Skip to main content

Lift Area Ratio — a population-independent model discrimination metric

Project description

LAR // Lift Area Ratio

A population-independent discrimination metric — interpretable alternative to ROC-AUC

[01] - why not AUC?

AUC averages performance across all thresholds equally. Two models can have the same AUC but behave very differently at your actual operating point.

// **LAR asks**
// how much better than random is my model at concentrating positives at the top of the ranking?


[02] - how it works

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

ERR = (b / n) / (B / N)

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

Three reference curves:

[oracle]  ERR starts at N/B -> drops once all positives are found  /* upper bound */
[model]   sits between oracle and random
[random]  ERR = 1 flat                                             /* no skill    */

LAR := ratio of areas above the random line:

LAR = A / O
    = area(model) / area(oracle)
    ∈ [0, 1]
LAR meaning
0.00 no skill
0.83 83% of perfect discrimination
1.00 oracle

// NOTE: event rate cancels out - directly comparable across datasets


[03] - install

$ pip install lift-area-ratio

[04] - usage

from lar import LiftAreaRatio

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

lar.summary(result)
# ================================================
#   N (observations) : 2000
#   B (positives)    : 197   | ER : 9.85%
#   max ERR (oracle) : 10.15
# ------------------------------------------------
#   area(model)      : 192.66
#   area(oracle)     : 231.72
#   LAR = A/O        : 0.8314  => 83.1% of perfect
# ================================================

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

[05] - API

LiftAreaRatio(n_percentiles=100)

  .fit(scores, y)  ->  LARResult
      scores  :: array-like  # higher = more likely positive
      y       :: array-like  # binary labels {0, 1}

  .summary(result)
  .plot(result, title, figsize, save=False, file_name="")

LARResult

.lar          # final score
.area_model   # area under model curve
.area_oracle  # area under oracle curve
.N            # total observations
.B            # total positives
.event_rate   # B / N
.lift_model   # DataFrame :: percentile, ERR per bin
.lift_oracle  # DataFrame :: percentile, ERR oracle

[06] - 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.4.tar.gz (5.9 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.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lift_area_ratio-0.1.4.tar.gz
  • Upload date:
  • Size: 5.9 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.4.tar.gz
Algorithm Hash digest
SHA256 2e3636ab8c8fc1161a19f6cf4923b3cf2807c5c86fdd021de25531d404ea148e
MD5 b5fc50797fe2c5277ec768f1bd86055c
BLAKE2b-256 39a1ab5a19eac6ccc1bae7fafb317a17fa4b6990033a8dc636758257a8686aef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lift_area_ratio-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 872b2cb0c832b128bc27fbcd54406e87a49555bbbecedcb2cc5de59db759c4a7
MD5 c19218c81bdb40b1ceb9298fed6b2c34
BLAKE2b-256 1904c0caa3d4b46397bc48684234fd86a074d97e8f889e0b1f75990fbfbbb34c

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