mean_relative_absolute_error#
- mean_relative_absolute_error(y_true, y_pred, horizon_weight=None, multioutput='uniform_average', **kwargs)[source]#
平均相对绝对误差 (MRAE)。
在相对误差度量中,首先通过将单个预测误差除以使用基准方法在相同索引位置计算的误差来计算相对误差。如果基准方法的误差为零,则返回一个较大的值。
MRAE 将平均绝对误差 (MAE) 应用于得到的相对误差。
- 参数:
- y_truepd.Series, pd.DataFrame 或 shape 为 (fh,) 或 (fh, n_outputs) 的 np.array,其中 fh 是预测范围
真实(正确)目标值。
- y_predpd.Series, pd.DataFrame 或 shape 为 (fh,) 或 (fh, n_outputs) 的 np.array,其中 fh 是预测范围
预测值。
- y_pred_benchmarkpd.Series, pd.DataFrame 或 shape 为 (fh,) 或 (fh, n_outputs) 的 np.array,其中 fh 是预测范围,默认 None
来自基准方法的预测值。
- horizon_weightshape 为 (fh,) 的 array-like,默认 None
预测范围权重。
- multioutput{‘raw_values’, ‘uniform_average’} 或 shape 为 (n_outputs,) 的 array-like,默认值为 ‘uniform_average’
定义如何聚合多变量(多输出)数据的指标。如果是 array-like,则值用作平均误差的权重。如果是 ‘raw_values’,则对于多输出输入返回完整的误差集。如果是 ‘uniform_average’,则所有输出的误差以统一权重平均。
- 返回:
- lossfloat
MRAE 损失。如果 multioutput 是 ‘raw_values’,则为每个输出分别返回 MRAE。如果 multioutput 是 ‘uniform_average’ 或权重的 ndarray,则返回所有输出误差的加权平均 MRAE。
另请参阅
参考文献
Hyndman, R. J and Koehler, A. B. (2006). “Another look at measures of forecast accuracy”, International Journal of Forecasting, Volume 22, Issue 4.
示例
>>> import numpy as np >>> from sktime.performance_metrics.forecasting import mean_relative_absolute_error >>> y_true = np.array([3, -0.5, 2, 7, 2]) >>> y_pred = np.array([2.5, 0.0, 2, 8, 1.25]) >>> y_pred_benchmark = y_pred*1.1 >>> mean_relative_absolute_error(y_true, y_pred, y_pred_benchmark=y_pred_benchmark) 0.9511111111111111 >>> y_true = np.array([[0.5, 1], [-1, 1], [7, -6]]) >>> y_pred = np.array([[0, 2], [-1, 2], [8, -5]]) >>> y_pred_benchmark = y_pred*1.1 >>> mean_relative_absolute_error(y_true, y_pred, y_pred_benchmark=y_pred_benchmark) 0.8703703703703702 >>> mean_relative_absolute_error(y_true, y_pred, y_pred_benchmark=y_pred_benchmark, multioutput='raw_values') array([0.51851852, 1.22222222]) >>> mean_relative_absolute_error(y_true, y_pred, y_pred_benchmark=y_pred_benchmark, multioutput=[0.3, 0.7]) 1.0111111111111108