feat(governance): add calibration metrics for segmentation confidence#51
Merged
Hopelynconsult merged 1 commit intodevelopfrom May 7, 2026
Merged
Conversation
ECE, MCE, Brier score, and reliability-bin computation for binary segmentation outputs. Threshold-driven NGO alerts depend on calibrated confidence: a model that says 0.9 should be right 90% of the time, and miscalibration translates directly into missed events or false alarms. The CalibrationReport dataclass slots into the existing model card generator and release CI gate. Pure numpy at evaluation time, no torch. - ReliabilityBin / CalibrationReport dataclasses with JSON serialisation - evaluate_calibration() one-shot entrypoint - write_calibration_report() for persistence alongside model cards - 12 tests covering perfect/overconfident calibration, edge cases, input validation, and round-trip JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
governance/calibration.pywith ECE, MCE, Brier score, and reliability-bin computation for binary segmentation outputs.CalibrationReportdataclass that serialises to JSON, ready to be attached alongside the existing Mitchell-style model cards (feat(governance): add automated model card generator #37) and consumed by the release CI gate (feat(governance): add release CI gate for metrics, fairness, and security #39).Why calibration matters here
ClimateVision dispatches NGO alerts based on confidence thresholds. A model that reports 0.9 confidence should be correct ~90% of the time; if it isn't, every threshold downstream is silently wrong, producing either missed events (deforestation, flood) or false alarms that erode NGO trust. We currently track accuracy/IoU/F1 but never measure whether the confidence we surface is meaningful. This closes that gap with the standard reliability-diagram metrics.
What's in the PR
ReliabilityBinandCalibrationReportdataclasses (JSON-serialisable, mirrors the style ofanomaly_detector.PredictionFeatures/model_card.ModelCard).evaluate_calibration()one-shot entrypoint returning a populated report.expected_calibration_error()(support-weighted),maximum_calibration_error()(worst-bin),brier_score().write_calibration_report()for persistence next to model cards inoutputs/.is_well_calibrated()helper with a 5% ECE default — wires straight into the release CI gate's threshold pattern.Follow-ups (separate PRs, not in scope here)
evaluate_calibrationintoscripts/generate_model_card.pyso every model card includes a calibration block.ecethreshold toscripts/governance_ci_gate.pyso miscalibrated releases fail the CI gate.Test plan
pytest tests/test_calibration.py -q→ 12 passedece_threshold=0.05,n_bins=15) match what we want for the release gate.🤖 Generated with Claude Code