Sub topic 9
Estimating Performance from Predicted Probabilities
Assume you know binary classification metrics, Python, NumPy, pandas, and scikit-learn. Also assume your prediction log stores a probability for the positive class, but current predictions do not have labels yet.
When labels arrive late, predicted probabilities can provide an early estimate of accuracy. This method is called confidence-based performance estimation (CBPE). It does not observe the true outcome for each row. Instead, it uses the model's confidence and depends on the probabilities being calibrated.
The basic idea
Suppose a model gives a probability of 0.9 for a transaction being fraudulent. If the model is calibrated, predictions near 0.9 are fraudulent about 90% of the time. If the classification threshold is 0.5, the model predicts fraud, so the expected probability of being correct is 0.9.
For a predicted probability of 0.2, the model predicts the negative class. Its expected probability of being correct is 1 - 0.2, or 0.8.
| Predicted probability | Predicted class at threshold 0.5 | Expected correctness |
|---|---|---|
| 0.90 | Positive | 0.90 |
| 0.20 | Negative | 0.80 |
| 0.50 | Positive | 0.50 |
The estimated accuracy is the mean expected correctness across the current batch:
\widehat{accuracy} = \frac{1}{n}\sum_i
\begin{cases}
p_i & \text{if } p_i \geq t \\
1-p_i & \text{if } p_i < t
\end{cases}Here, p is the predicted positive probability and t is the classification threshold.
import numpy as np
def expected_accuracy(p_positive, threshold=0.5):
"""Estimate binary accuracy without observing current labels."""
p = np.asarray(p_positive, dtype=float)
if np.any((p < 0) | (p > 1)):
raise ValueError("Probabilities must be between 0 and 1.")
predicted_positive = p >= threshold
probability_correct = np.where(
predicted_positive,
p,
1.0 - p,
)
return float(probability_correct.mean())
current_scores = np.array([0.95, 0.80, 0.40, 0.10, 0.55])
estimate = expected_accuracy(current_scores)
print(f"Estimated accuracy: {estimate:.3f}")The estimate is useful only as a statement about expected performance under the calibration assumption. It is not a measured accuracy.
Calibration is the key assumption
A model is calibrated when predicted probabilities match observed frequencies. For example, among 1,000 cases assigned a probability near 0.7, about 700 should be positive.
A model can rank examples correctly while still being poorly calibrated. ROC AUC measures ranking, not whether a probability of 0.7 means a 70% chance. Calibration can change after deployment because the population, data pipeline, or model behavior changes.
Check calibration on a historical validation set with labels. Reliability diagrams and metrics such as Brier score can help. If the model was calibrated on an old population, compare calibration across time and important groups.
What this method can and cannot estimate
CBPE is most direct for expected accuracy. With additional assumptions, predicted probabilities can also estimate class counts and parts of a confusion matrix. Precision and recall are harder because they depend on the joint relationship between predictions and outcomes, not only the average probability.
The estimate becomes unreliable when:
- probabilities are miscalibrated;
- the feature or outcome distribution has changed;
- the model's error pattern differs between historical and current data;
- the current batch is too small;
- the classification threshold changed but the calculation still uses the old threshold.
Use drift checks and delayed, matured labels together. Store estimates by prediction-time cohort so you can compare each estimate with its later measured metric.
Exercise
Exercise
A batch has predicted probabilities [0.9, 0.6, 0.4, 0.1]. What is its expected accuracy at threshold 0.5?
Show answer
The expected correctness values are 0.9, 0.6, 0.6, and 0.9. Their mean is 0.75, so the estimated accuracy is 75%, assuming calibration.