Skip to content

Single-series evaluation

This section documents evaluation utilities for single time series.

Single-series evaluation supports focused analysis of forecast accuracy and diagnostics for an individual series without cross-entity aggregation.

eb_evaluation.dataframe.single

Single-slice CWSL evaluation (DataFrame utilities).

This module provides a lightweight DataFrame wrapper around eb_metrics.metrics.cwsl for computing Cost-Weighted Service Loss (CWSL) on a single slice of data (i.e., the entire DataFrame provided).

It supports both scalar costs and per-row cost columns for asymmetric cost evaluation.

compute_cwsl_df(df, y_true_col, y_pred_col, cu, co, sample_weight_col=None)

Compute CWSL from a DataFrame.

This is a convenience wrapper around eb_metrics.metrics.cwsl that accepts a pandas DataFrame and column names.

Costs can be specified either as scalars or as per-row columns.

Parameters:

Name Type Description Default
df DataFrame

Input table containing at least the actual and forecast columns, and optionally cost/weight columns.

required
y_true_col str

Name of the column containing actual demand values.

required
y_pred_col str

Name of the column containing forecast values.

required
cu float | str

Underbuild (shortfall) cost coefficient.

  • If float: scalar cost applied uniformly across all rows.
  • If str: name of a column in df containing per-row underbuild costs.
required
co float | str

Overbuild (excess) cost coefficient.

  • If float: scalar cost applied uniformly across all rows.
  • If str: name of a column in df containing per-row overbuild costs.
required
sample_weight_col str | None

Optional column name containing non-negative sample weights per row. If None, all rows are weighted equally.

None

Returns:

Type Description
float

The Cost-Weighted Service Loss (CWSL) value for the provided DataFrame slice.

Raises:

Type Description
KeyError

If any required columns are missing.

ValueError

If the underlying eb_metrics.metrics.cwsl raises due to invalid values.

Notes

This function performs minimal validation and delegates metric validation to eb_metrics.metrics.cwsl.