# solarforecastarbiter.metrics.deterministic.error_band_cost¶

solarforecastarbiter.metrics.deterministic.error_band_cost(obs, fx, cost_params, error_fnc=<function error>)[source]

Compute cost according to various functions applied to specified error bands. The cost_params parameters is a solarforecastarbiter.datamodel.ErrorBandCost object. The cost_params.bands attribute lists the cost function (one of constant_cost(), time_of_day_cost(), datetime_cost()) that will apply to periods where the error (as calculated by error_fnc) falls within the given range.

To calculate the final cost value, the forecast error is calculated with error_fnc, then this error is compared with the range in each cost_params.bands. If the error falls within the range, the cost function associated with the range is applied to the error and added to the final result until all errors are evaluated.

In mathematical terms, if $$R_j$$ is the range of band $$j$$ and $$S$$ is the error function defined by error_fnc, the forecasts and observations are first split into sets according to

$\{\text{obs}^j, \text{fx}^j\} = \left\{\text{obs}_i, \text{fx}_i \forall i \text{ s.t. } S(\text{obs}_i, \text{fx}_i) \in R_j \text{ and } S(\text{obs}_i, \text{fx}_i) \notin \{R_1, \ldots, R_{j-1}\} \right\}$

Then, the cost function for each band, $$K_j(\cdot)$$ (as described by constant_cost(), time_of_day_cost(), and datetime_cost()), is applied to each set, yiedling

$\text{cost} = \sum_j K_j(\text{obs}^j, \text{fx}^j)$
Parameters: obs ((n,) pandas.Series) – Observed values with a pandas.DatetimeIndex. fx ((n,) pandas.Series) – Forecasted values with a pandas.DatetimeIndex matching obs. cost_params (solarforecastarbiter.datamodel.ErrorBandCost) – Parameters that the define the cost value along with how to aggregate the costs. error_fnc (function) – A function that returns the error, default fx - obs. First argument is obs, second argument is fx. cost (float) – The cost of the forecast errors.