.. toctree:: :maxdepth: 3 :caption: MedAE - Median Absolute Error
.. toctree:: :maxdepth: 3
.. toctree:: :maxdepth: 3
.. toctree:: :maxdepth: 3
\text{MedAE}(y, \hat{y}) = \text{median}(\mid y_1 - \hat{y}_1 \mid, \ldots, \mid y_n - \hat{y}_n \mid)
Latex equation code:
\text{MedAE}(y, \hat{y}) = \text{median}(\mid y_1 - \hat{y}_1 \mid, \ldots, \mid y_n - \hat{y}_n \mid)
The Median Absolute Error (MedAE) :cite:`nguyen2022improved` is particularly interesting because it is robust to outliers. The loss is calculated by taking the median of all absolute differences between the target and the prediction.
- Best possible score is 0.0, smaller value is better. Range = [0, +inf)
Example to use MedAE metric:
from numpy import array
from permetrics.regression import RegressionMetric
## For 1-D array
y_true = array([3, -0.5, 2, 7])
y_pred = array([2.5, 0.0, 2, 8])
evaluator = RegressionMetric(y_true, y_pred)
print(evaluator.max_error())
## For > 1-D array
y_true = array([[0.5, 1], [-1, 1], [7, -6]])
y_pred = array([[0, 2], [-1, 2], [8, -5]])
evaluator = RegressionMetric(y_true, y_pred)
print(evaluator.ME(multi_output="raw_values"))