What MAE (Mean Absolute Error) Meaning, Applications & Example
Mean Absolute Error, a regression evaluation metric.
What is MAE (Mean Absolute Error)?
MAE (Mean Absolute Error) is a metric used to evaluate the performance of a regression model . It calculates the average of the absolute differences between the predicted values and the actual values, giving an idea of how far off the predictions are from the true values.
Formula of MAE
\[ MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i - \hat{y}_i| \]Where:
- \( y_i \) is the actual value
- \( \hat{y}_i \) is the predicted value
- \( n \) is the number of data points
Applications of MAE
- Model Evaluation : Helps in comparing the performance of different regression models by assessing their prediction accuracy.
- Forecasting: Used in time series prediction to measure how well a model predicts future values.
- Error Analysis: Provides insight into the magnitude of prediction errors.
Example of MAE
import numpy as np
# Actual and predicted values
y_true = np.array([3, -0.5, 2, 7])
y_pred = np.array([2.5, 0.0, 2, 8])
# Calculate MAE
mae = np.mean(np.abs(y_true - y_pred))
print(f'Mean Absolute Error: {mae}')