Model Evaluation Metrics: Accuracy, Precision, Recall, F1, AUC, RMSE, and More
Understand all major ML evaluation metrics for classification and regression, learn when to use each one, and avoid common metric selection mistakes.
Model Evaluation Metrics: Accuracy, Precision, Recall, F1, AUC, RMSE, and More
Choosing the right metric is as important as choosing the right algorithm. A model that looks great by one metric may be terrible by another. This guide covers all major metrics for classification and regression, explains when to use each, and helps you avoid common mistakes.
---
Classification Metrics
Confusion Matrix — The Foundation
Every classification metric is derived from the confusion matrix:
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actually Positive | True Positive (TP) | False Negative (FN) |
| Actually Negative | False Positive (FP) | True Negative (TN) |
- TP: Correctly predicted positive (e.g., caught a fraudulent transaction)
- FP: Incorrectly predicted positive (e.g., flagged a legitimate transaction as fraud)
- FN: Missed a positive (e.g., fraud slipped through)
- TN: Correctly predicted negative (e.g., legitimate transaction correctly allowed)
Accuracy
Formula: (TP + TN) / (TP + TN + FP + FN)
The percentage of correct predictions.
| When to Use | When NOT to Use |
|---|---|
| Balanced classes (50/50) | Imbalanced classes (99/1) |
| All errors are equally costly | Missing a positive is much worse than a false alarm |
Precision
Formula: TP / (TP + FP)
Of all items the model predicted as positive, how many were actually positive?
Use when: False positives are costly.
- Spam detection (marking a real email as spam is bad)
- Drug approval (approving an unsafe drug is dangerous)
Recall (Sensitivity, True Positive Rate)
Formula: TP / (TP + FN)
Of all actually positive items, how many did the model catch?
Use when: Missing a positive is costly.
- Cancer screening (missing cancer is dangerous)
- Fraud detection (letting fraud through is costly)
- Security threats (missing a threat is unacceptable)
F1 Score
Formula: 2 × (Precision × Recall) / (Precision + Recall)
The harmonic mean of precision and recall. Balances both.
Use when: You need a single metric that considers both false positives and false negatives, especially with imbalanced data.
| F1 Score | Interpretation |
|---|---|
| 1.0 | Perfect precision and recall |
| 0.5 | Moderate performance |
| 0.0 | Completely wrong |
Precision-Recall Tradeoff
Improving precision usually hurts recall and vice versa. Adjusting the classification threshold moves you along this tradeoff:
- Higher threshold (e.g., 0.8): Fewer positive predictions → Higher precision, lower recall
- Lower threshold (e.g., 0.3): More positive predictions → Lower precision, higher recall
Specificity (True Negative Rate)
Formula: TN / (TN + FP)
Of all actually negative items, how many were correctly identified as negative?
AUC-ROC
The ROC curve plots True Positive Rate (recall) vs False Positive Rate (1 - specificity) at all thresholds.
AUC (Area Under the Curve) summarizes the curve in a single number:
| AUC Value | Interpretation |
|---|---|
| 1.0 | Perfect model |
| 0.9-1.0 | Excellent |
| 0.8-0.9 | Good |
| 0.7-0.8 | Fair |
| 0.5 | Random guessing (useless) |
| < 0.5 | Worse than random |
AUC-PR (Precision-Recall AUC)
Better than AUC-ROC for imbalanced datasets because it focuses on the positive class.
Log Loss (Cross-Entropy)
Penalizes confident wrong predictions more severely. Measures how well predicted probabilities match actual outcomes.
| Log Loss | Interpretation |
|---|---|
| 0 | Perfect predictions |
| < 0.3 | Good |
| 0.5-1.0 | Moderate |
| > 1.0 | Poor |
Multi-Class Classification Metrics
When there are more than 2 classes (e.g., "cat", "dog", "bird"):
| Averaging Method | How It Works |
|---|---|
| Macro | Compute metric per class, then average (treats all classes equally) |
| Weighted | Compute metric per class, then weighted average by class size |
| Micro | Compute globally across all classes |
---
Regression Metrics
MAE (Mean Absolute Error)
Formula: Average of |actual - predicted|
The average magnitude of errors, in the same units as the target.
| MAE | Interpretation |
|---|---|
| 0 | Perfect |
| Small relative to target range | Good |
| Close to target's standard deviation | Poor |
RMSE (Root Mean Squared Error)
Formula: √(Average of (actual - predicted)²)
Similar to MAE but penalizes large errors more heavily.
| MAE vs RMSE | Implication |
|---|---|
| MAE ≈ RMSE | Errors are similar in size |
| RMSE >> MAE | Some predictions have very large errors |
MSE (Mean Squared Error)
The square of RMSE. Same information but in squared units (harder to interpret).
R² (R-Squared, Coefficient of Determination)
Formula: 1 - (Sum of squared residuals / Sum of squared deviations from mean)
The proportion of variance in the target explained by the model.
| R² Value | Interpretation |
|---|---|
| 1.0 | Perfect (model explains all variance) |
| 0.8-1.0 | Good |
| 0.5-0.8 | Moderate |
| 0.0 | Model is no better than predicting the mean |
| < 0 | Model is worse than predicting the mean |
MAPE (Mean Absolute Percentage Error)
Formula: Average of |actual - predicted| / |actual| × 100%
Error as a percentage of the actual value.
| Pros | Cons |
|---|---|
| Easy to interpret (e.g., "5% off") | Undefined when actual = 0 |
| Scale-independent | Asymmetric: penalizes over-predictions less |
Metric Selection Guide
Classification
| Situation | Recommended Metric |
|---|---|
| Balanced classes, equal error costs | Accuracy |
| Imbalanced classes | F1, AUC-PR |
| Missing positives is costly (disease, fraud) | Recall |
| False alarms are costly (spam filter) | Precision |
| Need to compare models at all thresholds | AUC-ROC |
| Predicted probabilities matter | Log Loss |
Regression
| Situation | Recommended Metric |
|---|---|
| Want interpretable error in original units | MAE |
| Large errors are especially bad | RMSE |
| Want to explain proportion of variance | R² |
| Want percentage-based error | MAPE |
Common Pitfalls
| Pitfall | Problem | Fix |
|---|---|---|
| Using accuracy on imbalanced data | Misleading high accuracy | Use F1, AUC-PR, or balanced accuracy |
| Comparing MAE across different scales | A MAE of 10 means nothing without context | Use MAPE or normalize by target range |
| Ignoring the business context | Model optimizes wrong metric | Choose metric based on real-world cost of errors |
| Only looking at one metric | Incomplete picture | Report 2-3 complementary metrics |
| Optimizing for training metrics | Overfitting | Always use cross-validation or test set metrics |
| Using R² alone for regression | Can be misleading with outliers | Check residual plots alongside R² |
Quick Reference
| Metric | Type | Range | Higher is Better? |
|---|---|---|---|
| Accuracy | Classification | 0-1 | Yes |
| Precision | Classification | 0-1 | Yes |
| Recall | Classification | 0-1 | Yes |
| F1 Score | Classification | 0-1 | Yes |
| AUC-ROC | Classification | 0-1 | Yes |
| Log Loss | Classification | 0-∞ | No (lower is better) |
| MAE | Regression | 0-∞ | No (lower is better) |
| RMSE | Regression | 0-∞ | No (lower is better) |
| R² | Regression | -∞ to 1 | Yes |
| MAPE | Regression | 0-∞% | No (lower is better) |
What's Next?
- [Cross-Validation Guide](cross-validation-guide) — Evaluate models reliably
- [Explain and Interpret Guide](explain-interpret-guide) — LIME, SHAP, confusion matrix, ROC
- [Bias-Variance Tradeoff](bias-variance-overfitting) — Why models overfit
- [ML Overview](ml-overview) — The complete ML workflow
Related Articles
Cross-Validation: Reliable Model Evaluation Techniques
Learn how to evaluate ML models reliably using k-fold, stratified, leave-one-out, and time series cross-validation to avoid overfitting and get honest performance estimates.
Model Explainability: LIME, SHAP, Feature Importance, and Metrics
What is model explainability, LIME and SHAP explained, feature importance charts, comparing models, and confusion matrix, ROC, and residual plots explained visually.
Machine Learning Overview: Workflow and Getting Started
A beginner-friendly recap of ML, classification vs regression vs clustering, the ML workflow (select, configure, train, evaluate, predict), and a 5-minute quick-start guide.
Bias-Variance Tradeoff: Understanding Overfitting and Underfitting
Master the bias-variance tradeoff, understand what causes overfitting and underfitting, learn how to detect them with learning curves, and apply regularization (L1/L2), early stopping, and cross-validation to build better models.
Was this helpful?