Machine Learning - Model Evaluation & Calibration
Evaluating statistical learning models requires metrics suited to classification thresholds, ranking quality, and probability calibration.
Confusion Matrix & Classification Metrics
For binary classification with positive () and negative () classes:
| Actual \ Predicted | Predicted Positive | Predicted Negative |
|---|---|---|
| Actual Positive () | True Positive () | False Negative () |
| Actual Negative () | False Positive () | True Negative () |
Core Derived Metrics
- Precision (Positive Predictive Value):
- Recall (Sensitivity / True Positive Rate):
- Specificity (True Negative Rate):
- False Positive Rate (Fall-out):
- Score (Harmonic Mean):
- Score: Setting emphasizes recall; setting emphasizes precision.
Evaluation Curves
1. Receiver Operating Characteristic (ROC) & AUC
- Axes: x-axis is , y-axis is .
- Properties: Invariant to class imbalance because both and evaluate within their respective true class populations.
- Area Under Curve (ROC-AUC): Probability that a randomly chosen positive example is ranked higher than a randomly chosen negative example. Random guessing yields .
2. Precision-Recall (PR) Curve
- Axes: x-axis is , y-axis is .
- Properties: Highly sensitive to class imbalance. When negatives heavily outnumber positives (e.g., fraud detection at 0.1% incidence), the PR curve and PR-AUC provide a more realistic assessment than ROC-AUC.
3. Cumulative Gain & Lift
- Lift: Ratio of positive responses found in the top selected population compared to a random sample:
Model Probability Calibration
A model with a high ROC-AUC may still produce output scores that do not reflect true posterior probabilities . For example, Gradient Boosted Decision Trees (GBDT) and Support Vector Machines (SVM) frequently produce uncalibrated scores that cluster away from extreme probabilities and .
A model is well-calibrated if, among samples assigned predicted probability , exactly 80% belong to the positive class:
Calibration Techniques
1. Platt Scaling (Univariate Logistic Regression)
Fits a scalar sigmoid transformation on raw model scores using an independent validation set:
Parameters are optimized via maximum likelihood (cross-entropy). Platt scaling is parametric and robust against overfitting on smaller calibration sets.
2. Isotonic Regression
A non-parametric approach that fits a piecewise constant monotonic step function :
Solved via the Pair-Adjacent Violators Algorithm (PAVA). It requires no parametric assumptions but demands larger calibration datasets to avoid overfitting.
3. Piecewise Linear Calibration
Partitions raw predictions into bins and fits monotonic linear slopes within each bin, guaranteeing a continuous, monotonically increasing calibrated curve.
Quantitative Calibration Metrics
- Brier Score: Mean squared error between predicted probabilities and actual binary outcomes : Lower values indicate better calibration and sharpness.
- Expected Calibration Error (ECE): Groups predictions into equal-width probability bins and measures the weighted average discrepancy:
Association Rule Metrics
For evaluating co-occurrence in market basket analysis and entity relationships:
- Support: Probability of observing both items and :
- Confidence (Strength): Conditional probability that item appears given :
- Lift: Ratio of observed joint probability to the expected probability under independence:
- : and are statistically independent.
- : Positive association ( and co-occur more frequently than chance).
- : Negative association (substitution effect).
- Leverage: Difference between joint probability and independent probability:

