Skip to main content

Core Electric Barometer error metrics, including asymmetric CWSL and standard forecast loss functions.

Project description

Electric Barometer Metrics (eb-metrics)

License: BSD-3-Clause Python Versions Docs Project Status

This repository contains the reference Python implementation of core metrics defined within the Electric Barometer research program.

eb-metrics provides operationally meaningful forecasting metrics designed to support readiness-oriented evaluation under asymmetric cost, service constraints, and deployment considerations.

Formal definitions, theoretical motivation, and conceptual framing for these metrics are maintained in the companion research repository: eb-papers.


Naming convention

Electric Barometer packages follow standard Python packaging conventions:

  • Distribution names (used with pip install) use hyphens
    e.g. pip install eb-metrics
  • Python import paths use underscores
    e.g. import eb_metrics

This distinction is intentional and consistent across the Electric Barometer ecosystem.


What This Library Provides

  • Asymmetric, cost-weighted loss metrics (e.g., Cost-Weighted Service Loss)
  • Service-level and readiness diagnostics (NSL, UD, HR@τ, FRS)
  • Classical regression metrics for baseline comparison and diagnostics
  • Cost-ratio and sensitivity utilities for asymmetric evaluation
  • Framework integrations for TensorFlow / Keras and scikit-learn

The library is lightweight, dependency-minimal, and fully unit-tested.


Scope

This repository focuses on metric implementation, not conceptual exposition.

In scope:

  • Executable implementations of Electric Barometer metrics
  • Consistent, validated APIs for loss and service evaluation
  • Integration layers for common ML frameworks

Out of scope:

  • Theoretical derivations and proofs
  • Governance or managerial frameworks
  • Empirical benchmarking studies
  • End-user tutorials

Installation

Once published, the package will be installable via PyPI:

pip install eb-metrics

For development or local use:

pip install -e .

Quick Usage Example

from eb_metrics.metrics.loss import cost_weighted_service_loss

loss = cost_weighted_service_loss(
    y_true=actual,
    y_pred=forecast,
    cost_ratio=R,
)

Examples are illustrative; consult function docstrings for full parameter definitions and return semantics.


Public API Overview

The primary public modules are:

  • eb_metrics.metrics.loss
    Asymmetric loss formulations (e.g., CWSL)

  • eb_metrics.metrics.service
    Service-level and readiness diagnostics (NSL, UD, HR@τ, FRS)

  • eb_metrics.metrics.regression
    Classical regression metrics

  • eb_metrics.metrics.cost_ratio
    Cost-ratio estimation and sensitivity utilities

  • eb_metrics.frameworks.keras_loss
    Keras-compatible loss wrappers

  • eb_metrics.frameworks.sklearn_scorer
    scikit-learn-compatible scoring interfaces

Users are encouraged to import from these modules rather than internal helpers.


Conventions

Electric Barometer metrics follow consistent operational conventions, including:

  • Explicit distinction between underbuild and overbuild
  • Asymmetric cost ratios expressed as (R = c_u / c_o)
  • Normalization relative to realized demand where applicable
  • Clear directionality (e.g., lower loss indicates better performance)

Detailed semantic conventions are documented separately.


Development and Testing

Tests are located under the tests/ directory and mirror the package structure.

To run tests:

pytest

Contributions should preserve alignment with definitions in eb-papers.


Relationship to Other EB Repositories

  • eb-papers
    Source of truth for conceptual definitions and evaluation philosophy.

  • eb-metrics
    Provides the metric implementations used during evaluation.

  • eb-evaluation
    Orchestrates evaluation workflows using adapted models.

  • eb-adapters
    Ensures heterogeneous models can be evaluated consistently.

When discrepancies arise, conceptual intent in eb-papers should be treated as authoritative.


Status

This package is under active development. Public APIs may evolve prior to the first stable release.

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

eb_metrics-0.1.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

eb_metrics-0.1.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eb_metrics-0.1.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for eb_metrics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e850e6c891ad0af31817242b0c31ed92fad0403a2d8bf3fc40d0cfe7dc9afac3
MD5 851fa0227cb102c3d299a237983f0191
BLAKE2b-256 f5d5b50bb0e0c2a8e15d9084bb1e840df3bae0230c201126c77c277885b2921d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eb_metrics-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for eb_metrics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12a0b707b95618520d69c9a64b51d3e9738657f4f24a81b1d2b827ade5509004
MD5 379010ef20f1d31ebd13dee6b08bf8e4
BLAKE2b-256 377afebff6d5791cd06857c019d098ac7f2d3518e1a677107e107b852a3947d0

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