Skip to main content

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

Project description

Electric Barometer · Metrics (eb-metrics)

CI License: BSD-3-Clause Python Versions PyPI

Asymmetric, readiness-oriented forecast evaluation metrics for operational decision systems.


Overview

eb-metrics provides a set of forecast evaluation metrics designed for operational environments where the consequences of error are asymmetric and interval-level reliability matters. Traditional accuracy measures such as RMSE or MAE treat overforecasting and underforecasting symmetrically and summarize average deviation, often obscuring whether a forecast is suitable for real-world execution.

The metrics in this package evaluate forecasts in terms of service protection, shortfall behavior, and cost-weighted impact. They are designed for readiness-oriented assessment in settings such as production, staffing, inventory, logistics, and short-horizon demand planning, where even small shortfalls can create disproportionate operational disruption. eb-metrics serves as the foundational metric layer of the Electric Barometer ecosystem, providing interpretable primitives that support decision-aligned forecast comparison and selection.


Role in the Electric Barometer Ecosystem

eb-metrics defines the core metric primitives used throughout the Electric Barometer ecosystem. It is responsible for implementing asymmetric loss, reliability, and readiness-oriented forecast evaluation measures in a form that is interpretable, composable, and operationally aligned.

This package focuses exclusively on metric definition and behavior. It does not manage data aggregation, evaluation workflows, model interfaces, feature construction, or integration testing. Those concerns are handled by adjacent layers in the ecosystem that apply, orchestrate, or consume these metrics in broader forecasting and decision-making pipelines.

By separating metric semantics from evaluation logic and execution concerns, eb-metrics provides a stable foundation that supports consistent, decision-aligned forecast assessment across heterogeneous operational contexts.


Installation

eb-metrics is distributed as a standard Python package.

pip install eb-metrics

The package supports Python 3.10 and later.


Core Concepts

  • Asymmetric error — Overforecasting and underforecasting can have different operational consequences, so evaluation should reflect directional cost differences.
  • Interval reliability — In readiness-oriented systems, it matters how often forecasts meet demand within each interval, not just average error over time.
  • Shortfall behavior — Underbuilding events are operationally distinct; evaluation should capture both their frequency and their severity.
  • Tolerance-based adequacy — Many systems can absorb small deviations; reliability can be expressed as the frequency of “accurate enough” intervals.
  • Readiness-oriented evaluation — Forecast quality is assessed by execution feasibility and risk, not solely statistical deviation.

Minimal Example

The following example computes Cost-Weighted Service Loss (CWSL) for a single demand series using asymmetric penalties for underbuild and overbuild:

import numpy as np
from eb_metrics import cwsl

# Realized demand and corresponding forecast
y_true = np.array([20, 28, 32, 35, 40, 42])
y_pred = np.array([22, 25, 29, 36, 37, 45])

# Compute cost-weighted service loss
loss = cwsl(
    y_true=y_true,
    y_pred=y_pred,
    underbuild_cost=2.0,
    overbuild_cost=1.0,
)

print(loss)

License

BSD 3-Clause License.
© 2025 Kyle Corrie.

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.2.1.tar.gz (19.2 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.2.1-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eb_metrics-0.2.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eb_metrics-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9a0fecd00824d0f7973fd0fd897cf0f6ec33557cce39478bbf3dc70c2eca7098
MD5 1b8957afd4ab90b8dc99b2bb18b867b7
BLAKE2b-256 d636c41c0004c273c2e6aefa74452e2e4ca342452443161f96237652542a0b29

See more details on using hashes here.

Provenance

The following attestation bundles were made for eb_metrics-0.2.1.tar.gz:

Publisher: release.yml on Economistician/eb-metrics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: eb_metrics-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eb_metrics-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b935535eabd81bc6724f5d14ae736c4fbfb9bde6fddc9884b18d7f944dcebd3
MD5 6d2a0d4685df83d224391cc4a7aecaa6
BLAKE2b-256 71910cf6d16fd15a125e2bcf123db3f1900e4f101efb9205a737f95de3272bde

See more details on using hashes here.

Provenance

The following attestation bundles were made for eb_metrics-0.2.1-py3-none-any.whl:

Publisher: release.yml on Economistician/eb-metrics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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