solarforecastarbiter.metrics.deterministic.datetime_cost

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

Compute cost using a date-time varying cost value. First, a pandas.Series of costs is constructed to match the index of obs and fx: cost_params.cost specifies the value to assign to each date-time in cost_params.datetimes. The cost_params.fill attribute specifies how to fill (forward or backward) the cost for date-times in the observation/forecast index but not in cost_params.datetimes. This cost series, along with the attributes net and aggregation from cost_params are used to perform the following calculation depending on (net, aggregation):

\[\begin{split}\text{cost} = \begin{cases} 1/n \sum_{i=1}^n C_i * S(\text{obs}_i, \text{fx}_i) & \text{True, mean} \\ \sum_{i=1}^n C_i * S(\text{obs}_i, \text{fx}_i) & \text{True, sum} \\ 1/n \sum_{i=1}^n C_i * |S(\text{obs}_i, \text{fx}_i)| & \text{False, mean} \\ \sum_{i=1}^n C_i * |S(\text{obs}_i, \text{fx}_i)| & \text{False, sum} \end{cases}\end{split}\]

where \(S\) is the error function defined by error_fnc and \(C\) is the computed cost series.

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.DatetimeCost) – 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.
Returns:

cost (float) – The cost of the forecast errors.

Notes

In the case where the specified cost_params.datetimes are insufficient to cover the observation/forecast index after filling, those missing date-times are excluded from the cost calculation.