Skip to main content

Python package to compute the Equal Error Rate, wrapping lrreval

Project description

Equal Error Rate

The Equal Error Rate is an overall performance metric for a binary classifier. It is insensitive to

  • evaluation priors, so the metric doesn't change if the relative amounts of data points in the two classes varies
  • calibration, so the classifier only needs to produce consistent scores, and not set a threshold

This package is a thin wrapper around llreval, which computes the equal error rate in the ROC convex hull interpretation, which is consistent and meaningful, see Niko Brümmer's PhD thesis.

Installation

pip install wer

Usage

Collect your classifier's (floating point) scores in a numpy array. Prepare a parallel array with values 0 for the class related to lower scores, and 1 for the class related to higher scores. Then call eer.eer(scores, labels).

Example:

Simulate calibrated scores for a binary classifier, and compute the equal error rate.

import numpy as np
from eer import eer, eer_tnt

ntar, nnon = 100_000, 1_000_000
targets = 2 + 2 * np.random.randn(ntar)
non_targets = -2 + 2 * np.random.randn(nnon)
print("EER using target and non-target scores:", eer_tnt(targets, non_targets))

scores = np.concatenate([targets, non_targets])
labels = np.concatenate([np.ones(targets.shape[0]), np.zeros(non_targets.shape[0])])
print("EER using scores and labels:", eer(scores, labels))

The values printed should not be too far from 0.5 + 0.5erf(-1/√2) ≈ 0.1586552.

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

eer-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

eer-0.0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file eer-0.0.2.tar.gz.

File metadata

  • Download URL: eer-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for eer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d19ca668603909aed0ba89304518c30ff85c9b86686d9a2e1cd4366434f31388
MD5 74630ab72597729566971fb8f9399d94
BLAKE2b-256 6d8ceb40774d5c6fdca45ee11996fdecdeeb28c4246c0690d10286cea387fe84

See more details on using hashes here.

File details

Details for the file eer-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: eer-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for eer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1b0dc3bcbeb0a95153d7e4e8e936cdc1e23f9ff8e921a97925a851fd4d440077
MD5 85fc8e9b3e5fde23a88c6b1caba19235
BLAKE2b-256 d661fe12d61422fa05cd48df81e9602811ae5b120bb8dee168e6e20a7fad5911

See more details on using hashes here.

Supported by

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