๐ After building a Machine Learning model, we must check:
โHow good is the model?โ
This is done using evaluation metrics.
๐น 1. Why Model Evaluation is Important?
โ Measures model performance
โ Detects errors
โ Helps compare models
โ Prevents bad predictions
๐ฅ 2. Evaluation Metrics for Regression
Used for predicting numbers
โ MAE (Mean Absolute Error)
๐ Average absolute error.
MAE = (1/n) ฮฃ |y - yฬ|
โ Lower MAE = Better model
โ MSE (Mean Squared Error)
๐ Squares the errors.
MSE = (1/n) ฮฃ (y - yฬ)^2
โ Punishes large errors more.
โ RMSE (Root Mean Squared Error)
RMSE = โMSE = โ[(1/n) ฮฃ (y - yฬ)^2]
โ Easy to interpret.
โ Rยฒ Score โญ
Measures how well model explains data.
Rยฒ = 1 - [ฮฃ(y - yฬ)^2 / ฮฃ(y - ศณ)^2]
Rยฒ = 1 โ Perfect model
โ Higher Rยฒ = Better performance
Where yฬ = predicted value, ศณ = mean of actual values
๐ฅ 3. Evaluation Metrics for Classification
Used for categories
โ Accuracy
Accuracy = Correct Predictions / Total Predictions
โ Precision
๐ Out of predicted positives, how many are correct?
Precision = TP / (TP + FP)
โ Recall
๐ Out of actual positives, how many detected?
Recall = TP / (TP + FN)
โ F1-Score โญ
Balance between precision & recall.
F1-Score = 2 (Precision ร Recall) / (Precision + Recall)
๐น 4. Confusion Matrix โญ
A table showing prediction results.
Actual Positive & Predicted Positive = TP (True Positive)
Actual Positive & Predicted Negative = FN (False Negative)
Actual Negative & Predicted Positive = FP (False Positive)
Actual Negative & Predicted Negative = TN (True Negative)
TP = model correctly predicted positive
TN = model correctly predicted negative
FP = model wrongly predicted positive
FN = model wrongly predicted negative
๐น 5. Implementation (Python)
from sklearn.metrics import accuracy_score
y_true = [0, 1, 1, 0]
y_pred = [0, 1, 0, 0]
print(accuracy_score(y_true, y_pred))
๐น 6. Why Metrics Matter?
โ Helps improve models
โ Used in interviews
โ Critical in real-world AI systems
๐ฏ Todayโs Goal
โ Understand regression metrics
โ Learn classification metrics
โ Understand confusion matrix
๐ฌ Tap โค๏ธ for more!