Skip to content

feat: add predict_uncertainty() for ensemble-based regression intervals#831

Open
Debi-Prasad-Panda wants to merge 1 commit into
mljar:masterfrom
Debi-Prasad-Panda:feat/predict-uncertainty
Open

feat: add predict_uncertainty() for ensemble-based regression intervals#831
Debi-Prasad-Panda wants to merge 1 commit into
mljar:masterfrom
Debi-Prasad-Panda:feat/predict-uncertainty

Conversation

@Debi-Prasad-Panda

Copy link
Copy Markdown

Summary

Adds automl.predict_uncertainty(X, alpha=0.05) for regression tasks, as discussed in the issue thread.

This method computes ensemble-based uncertainty intervals using predictions from all sub-models selected in the Ensemble. For each sample:

  • prediction = weighted mean of sub-model predictions
  • prediction_variance = weighted variance of sub-model predictions
  • prediction_std = sqrt(prediction_variance)
  • lower = prediction - z * prediction_std
  • upper = prediction + z * prediction_std

where z = norm.ppf(1 - alpha/2) (e.g., z ≈ 1.96 for alpha=0.05).

Important: This is documented as an ensemble disagreement interval, not a statistically calibrated confidence interval.

Changes

  • supervised/automl.py — Added public predict_uncertainty() method with full docstring.
  • supervised/base_automl.py — Added internal _predict_uncertainty() with:
    • Regression-only validation
    • Automatic Ensemble fallback when best model is a single algorithm
    • Weighted mean/variance/std computation across sub-models
    • Z-score based interval bounds
  • tests/tests_automl/test_predict_uncertainty.py — 5 unit tests covering:
    • Before fit
    • Classification task (rejected)
    • No Ensemble available (rejected)
    • Ensemble fallback from single best model
    • Full regression success with output validation

Output Format

prediction prediction_std prediction_variance lower upper

@Debi-Prasad-Panda

Debi-Prasad-Panda commented Jun 11, 2026

Copy link
Copy Markdown
Author

Hi @pplonski, apologies for the delay on this — I had a family loss. I've now opened a PR implementing predict_uncertainty() as discussed.

It follows the exact spec you outlined — weighted mean, variance, std from ensemble sub-model predictions, with z-score based intervals from the alpha parameter. The output is a DataFrame with columns: prediction, prediction_std, prediction_variance, lower, upper.

I've also added an automatic fallback so it works even when the best model selected by AutoML is a single algorithm (it finds and uses the trained Ensemble internally).

5 unit tests are included covering all edge cases. Looking forward to your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant