mean_absolute_percentage_error#

skfda.misc.scoring.mean_absolute_percentage_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')[source]#
skfda.misc.scoring.mean_absolute_percentage_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')
skfda.misc.scoring.mean_absolute_percentage_error(y_true: DataType, y_pred: DataType, *, sample_weight: NDArrayFloat | None = None, multioutput: Literal['uniform_average'] = 'uniform_average') float
skfda.misc.scoring.mean_absolute_percentage_error(y_true: DataType, y_pred: DataType, *, sample_weight: NDArrayFloat | None = None, multioutput: Literal['raw_values']) DataType

Mean Absolute Percentage Error for FData.

With \(y\_true = (X_1, X_2, ..., X_n)\) being the real values, \(t\_pred = (\hat{X}_1, \hat{X}_2, ..., \hat{X}_n)\) being the estimated and \(sample\_weight = (w_1, w_2, ..., w_n)\), the error is calculated as

\[MAPE(y\_true, y\_pred)(t) = \frac{1}{\sum w_i} \sum_{i=1}^n w_i\frac{|X_i(t) - \hat{X}_i(t)|}{|X_i(t)|}\]

For \(y\_true\) and \(y\_pred\) of type FDataGrid, \(MAPE\) is also a FDataGrid object with the same grid points.

If multioutput = ‘raw_values’, the function \(MAPE\) is returned. Otherwise, if multioutput = ‘uniform_average’, the mean of \(MAPE\) is calculated:

\[mean(MAPE) = \frac{1}{V}\int_{D} MAPE(t) dt\]

where \(D\) is the function domain and \(V\) the volume of that domain.

For FDataBasis only ‘uniform_average’ is available.

If \(y\_true\) and \(y\_pred\) are numpy arrays, sklearn function is called.

This function should not be used if for some \(t\) and some \(i\), \(X_i(t) = 0\).

Parameters:
  • y_true – Correct target values.

  • y_pred – Estimated values.

  • sample_weight – Sample weights. By default, uniform weights are taken.

  • multioutput – Defines format of the return.

Returns:

Mean absolute percentage error.

If multioutput = ‘uniform_average’ or \(y\_pred\) and \(y\_true\) are FDataBasis objects, float is returned.

If both \(y\_pred\) and \(y\_true\) are FDataGrid objects and multioutput = ‘raw_values’, FDataGrid is returned.

If both \(y\_pred\) and \(y\_true\) are ndarray and multioutput = ‘raw_values’, ndarray.