Classification Metrics Deep Dive
Confusion matrix, precision, recall, F1, ROC-AUC, PR curve — choosing the right metric.
Accuracy Is Not Enough
Accuracy is the fraction of correct predictions, but it misleads on imbalanced data. A model predicting only the majority class can score 99% while being useless for the rare class.
The Confusion Matrix
The confusion matrix breaks predictions into true positives, false positives, true negatives, and false negatives. It is the foundation for all other metrics.
from sklearn.metrics import confusion_matrix
y_true = [0, 1, 1, 0, 1, 0]
y_pred = [0, 1, 0, 0, 1, 1]
print(confusion_matrix(y_true, y_pred))
# rows = actual, columns = predictedAll lessons in this course
- Cross-Validation Strategies
- Classification Metrics Deep Dive
- Grid Search and Random Search
- Bayesian Optimization with Optuna