Skip to main content

A family of metrics for principled evaluation of uncertainty-augmented systems

Project description

ECUAS: Expected Cost for Uncertainty-Augmented Systems

ecuas is a Python library containing popular calibration and classification evaluation metrics, alongside the principled ECUAS metric family, for Uncertainty-Augmented (UA) systems.

This library implements the ECUAS_n metric family described in the paper: ECUAS_n: A family of metrics for principled evaluation of uncertainty-augmented systems.

Background

In high-stakes automated decision-making, access to predictive uncertainty is essential for enabling users to accept or reject predictions based on application-specific cost trade-offs.

Traditional evaluation approaches assess these systems using separate metrics for candidate predictions (e.g., accuracy) and uncertainty scores (e.g., AUC, ECE, Brier Score), or by integrating over risk-coverage curves (e.g., AURC) that ignore probabilistically interpretable uncertainties.

ECUAS solves this by providing a unified, decision-theory-based proper scoring rule (PSR) to comprehensively evaluate the task of interest. The parameter $n$ controls the trade-off between the cost of incorrect predictions and imperfect uncertainties:

  • A small value (e.g., $n=0$) heavily penalizes systems that give high confidence to incorrect answers, suitable for settings where accepting an incorrect answer has severe consequences.
  • A large value (e.g., $n \rightarrow \infty$) acts more like the 0-1 cost error rate, giving milder penalties to confident-but-incorrect predictions.

Installation

Via uv (Recommended)

Add ecuas directly to your project:

uv add ecuas

Via pip

You can install ecuas from PyPI:

pip install ecuas

Features and Metrics

Confidence/Selective Prediction Metrics

  • Expected Calibration Error (ECE): ExpectedCalibrationError
  • Confidence Error Rate: ConfidenceErrorRate
  • Confidence AUC Score: ConfidenceAUCScore
  • Confidence Brier Score: ConfidenceBrierScore
  • Confidence Cross-Entropy: ConfidenceCrossEntropy
  • Confidence ECUAS (n-ECUAS): ConfidenceECUAS
  • Confidence Gamma-ECUAS: ConfidenceGammaECUAS
  • Confidence AURC: ConfidenceAURC
  • CCAS (Confidence Cost for Selective Prediction): CCAS

Classification Metrics

  • Classification Error Rate: ClassificationErrorRate
  • Classification Cross-Entropy: ClassificationCrossEntropy
  • Classification Brier Score: ClassificationBrierScore
  • Classification AUC: ClassificationAUC
  • Classification ECE: ClassificationECE
  • Classification ECUAS: ClassificationECUAS
  • Classification LogLog: ClassificationLogLog
  • Classification Gamma-ECUAS: ClassificationGammaECUAS
  • Classification AURC: ClassificationAURC

Usage Example

import torch
from ecuas import ConfidenceECUAS, ExpectedCalibrationError

# Setup data
confidences = torch.tensor([0.9, 0.8, 0.4, 0.9])
correctness = torch.tensor([True, True, False, False])

# Expected Calibration Error
ece_metric = ExpectedCalibrationError(n_bins=10)
ece_metric.update(confidences, correctness)
ece_val = ece_metric.compute()
print(f"ECE: {ece_val.item():.4f}")

# Confidence n-ECUAS (e.g., n=0 to heavily penalize overconfident errors)
ecuas_metric = ConfidenceECUAS(n=0)
ecuas_metric.update(confidences, correctness)
ecuas_val = ecuas_metric.compute()
print(f"ECUAS (n=0): {ecuas_val.item():.4f}")

Running Tests

Execute the unit test suite:

uv run pytest

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

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

ecuas-0.1.4.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

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

ecuas-0.1.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ecuas-0.1.4.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for ecuas-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6fca81abfba5efd0b859e303d093bdde087bc8dd38806039d7fda47bc3009369
MD5 dacf7f4ddfcc3a5aedf76953b6c6cc09
BLAKE2b-256 a90d1a2fa96c60acd528030a0d498af041040e81eb9abd53e6e97cf942bce227

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ecuas-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for ecuas-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 de051d36dc89f88a97b35c55fa1c4aeeb3155c3015ea6739a65d392d6b3965a8
MD5 1fd733cfb2cd2f972b78d8a81b3b7dc5
BLAKE2b-256 09c3056209f30afa5dd0147d837597c8caa50948d147f2f4d2a2b2a17231ba1b

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