ddop.metrics.average_costs

ddop.metrics.average_costs(y_true, y_pred, cu, co, multioutput='uniform_average')

Compute average costs based on the the difference between y_true and y_pred and the given underage and overage costs.

Parameters
  • y_true (array-like) – The true values

  • y_pred (array-like) – The predicted vales

  • cu (int or float) – the underage costs per unit.

  • co (int or float) – the overage costs per unit.

  • multioutput ({"raw_values", "uniform_average"}, default="raw_values") –

    Defines aggregating of multiple output values. Default is “raw_values”.
    ’raw_values’ :

    Returns a full set of cost values in case of multioutput input.

    ’uniform_average’ :

    Costs of all outputs are averaged with uniform weight.

Returns

costs – The average costs. If multioutput is ‘raw_values’, then the average costs are returned for each output separately. If multioutput is ‘uniform_average’, then the average of all output costs is returned. The average costs are non-negative floating points. The best value is 0.0.

Return type

float or ndarray of floats

Examples

>>> from ddop.metrics import average_costs
>>> y_true = [[2,2], [2,4], [3,6]]
>>> y_pred = [[1,2], [3,3], [4,7]]
>>> cu = [2,4]
>>> co = [1,1]
>>> average_costs(y_true, y_pred, cu, co, multioutput="raw_values")
array([1.33.., 1.66..])
>>> average_costs(y_true, y_pred, cu, co, multioutput="uniform_average")
1.5