Regression models evaluation - metrics

 Yes! Apart from RMSE, you can use multiple other evaluation metrics depending on your problem type (regression or classification). Since you're working on a regression problem, here are some key alternatives:


📌 1. Mean Absolute Error (MAE)

MAE=1ni=1nyiyi^MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i - \hat{y_i}|

✅ Measures the average absolute difference between actual and predicted values.
✅ Less sensitive to large errors compared to RMSE.
🚫 Doesn’t penalize large errors as heavily as RMSE.

📌 Use When: You want a simple, interpretable metric without giving more weight to large errors.


📌 2. Mean Squared Error (MSE)

MSE=1ni=1n(yiyi^)2MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y_i})^2

✅ Squaring the errors gives more weight to larger errors.
✅ Helps identify models that make large mistakes.
🚫 Hard to interpret since it’s in squared units.

📌 Use When: You want to penalize large errors more severely.


📌 3. Mean Absolute Percentage Error (MAPE)

MAPE=1ni=1nyiyi^yi×100MAPE = \frac{1}{n} \sum_{i=1}^{n} \left| \frac{y_i - \hat{y_i}}{y_i} \right| \times 100

✅ Expresses error as a percentage, making it easy to interpret.
🚫 Can be unreliable if actual values are very close to zero.

📌 Use When: You need a scale-independent metric (e.g., comparing performance across different datasets).


📌 4. R-Squared (R²) – Coefficient of Determination

R2=1(yiyi^)2(yiyˉ)2R^2 = 1 - \frac{\sum (y_i - \hat{y_i})^2}{\sum (y_i - \bar{y})^2}

✅ Measures how well the model explains variance in the data.
✅ Values range from 0 to 1 (closer to 1 is better).
🚫 Doesn’t tell you how good your predictions are in absolute terms.

📌 Use When: You want to know how well your model fits the data overall.


📌 5. Adjusted R-Squared

✅ Similar to , but adjusts for the number of predictors in the model.
🚫 Helps avoid overfitting in complex models with many variables.

📌 Use When: You have multiple independent variables and want a more reliable goodness-of-fit measure.


🔍 Choosing the Right Metric

MetricInterpretationBest Used When
RMSEPenalizes large errorsGeneral regression models
MAEAbsolute error, easier to interpretWhen you need simplicity
MSEPenalizes large errors moreHandling outliers
MAPEExpresses error in %When target values vary widely
Measures model fitWhen checking variance explanation
Adjusted R²Improves R² for multiple featuresWhen avoiding overfitting

🛠 Example: Calculating These Metrics in Python

python
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score # Example data y_true = [100, 200, 300, 400, 500] y_pred = [110, 195, 290, 405, 495] # Compute metrics mae = mean_absolute_error(y_true, y_pred) mse = mean_squared_error(y_true, y_pred) rmse = mean_squared_error(y_true, y_pred, squared=False) r2 = r2_score(y_true, y_pred) # Print results print(f"MAE: {mae}") print(f"MSE: {mse}") print(f"RMSE: {rmse}") print(f"R² Score: {r2}")

Would you like help choosing the best metric for your dataset? 🚀

No comments

Theme images by tjasam. Powered by Blogger.