macro_averaged_mean_absolute_error#
- imblearn.metrics.macro_averaged_mean_absolute_error(y_true, y_pred, *, sample_weight=None)[source]#
Compute Macro-Averaged MAE for imbalanced ordinal classification.
This function computes each MAE for each class and average them, giving an equal weight to each class.
Read more in the User Guide.
Added in version 0.8.
- Parameters:
- y_truearray-like of shape (n_samples,) or (n_samples, n_outputs)
Ground truth (correct) target values.
- y_predarray-like of shape (n_samples,) or (n_samples, n_outputs)
Estimated targets as returned by a classifier.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns:
- lossfloat or ndarray of floats
Macro-Averaged MAE output is non-negative floating point. The best value is 0.0.
Examples
>>> import numpy as np >>> from sklearn.metrics import mean_absolute_error >>> from imblearn.metrics import macro_averaged_mean_absolute_error >>> y_true_balanced = [1, 1, 2, 2] >>> y_true_imbalanced = [1, 2, 2, 2] >>> y_pred = [1, 2, 1, 2] >>> mean_absolute_error(y_true_balanced, y_pred) 0.5 >>> mean_absolute_error(y_true_imbalanced, y_pred) 0.25 >>> macro_averaged_mean_absolute_error(y_true_balanced, y_pred) 0.5 >>> macro_averaged_mean_absolute_error(y_true_imbalanced, y_pred) 0.16...