Skip to content

Conversation

@fleur-petit
Copy link
Collaborator

@fleur-petit fleur-petit commented Dec 19, 2025

Summary

This PR implements a postprocessing calibration method for quantile estimation using sk-learn's IsotonicRegression.

Changes

  • Added IsotonicCalibrator to postprocessing transforms.
  • Added tests to check IsotonicCalibrator functionality on different data with different settings.
  • Added example with visualisation to show the effect of IsotonicCalibrator on observed vs expected quantiles

Testing

  • Existing tests pass
  • New tests test new calibration method in different scenario's
  • Example script to visually inspect effect of isotonic calibration on observed vs expected quantiles.

Signed-off-by: Fleur Petit <fleur.petit@alliander.com>
Signed-off-by: Fleur Petit <fleur.petit@alliander.com>
@fleur-petit fleur-petit force-pushed the feature/673-calibration-isotonic-quantile branch from 4bd91ed to 469f92c Compare December 19, 2025 13:11
@egordm egordm added feature New feature or request OpenSTEF 4.0 Work for OpenSTEF 4.0 labels Dec 19, 2025
@egordm egordm self-requested a review December 19, 2025 15:43
Comment on lines +132 to +135
# Remove NaN values (required for IsotonicRegression)
mask = ~(np.isnan(predictions) | np.isnan(actuals))
predictions_clean = predictions[mask]
actuals_clean = actuals[mask]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calibriation can be quite tricky in case we have a very small data. To limit this risk we could introduce a warning or condition on the number of datapoints. If the fraction or absolute number of datapoints is below this threshold, we can warn the user or even skip the calibration entirely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .05 is a bit arbitrary, what do you think?

Returns:
Array of locally estimated quantile values matching the input order.
"""
# Sort by predicted values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set a lower limit on the length of the window? If we use the np.quantile we need at least 100 observations. Otherwise we risk Q50 == Q51

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

Labels

feature New feature or request OpenSTEF 4.0 Work for OpenSTEF 4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants