The forecast interval that excludes its edges
An empirical coverage metric undercounts correct forecasts when the observed value equals an interval endpoint.
What’s going wrong
ML practice. Historical teaching adaptation of a repaired sktime defect, written independently for Bugger. This is not an official GSoC task or a currently open issue to resubmit.
A forecast evaluation reports that a prediction interval missed an observation even though the observation equals its lower or upper bound. Repair interval_coverage so the metric follows the declared closed-interval contract.
Input is {"rows":[{"truth":2,"lower":2,"upper":5},...]}. Each row is one observation with its own forecast interval. An observation is covered exactly when lower <= truth <= upper. Endpoints count, including the single value of a zero-width interval. Duplicate rows are separate observations; do not deduplicate them.
Print {"covered":3,"total":4,"coverage":0.75}, where covered is the number of covered rows, total is the number of rows, and coverage is Python round(covered / total, 6). If total is zero, print covered 0, total 0 and coverage null. The rows array has 0 to 100 items. Each truth, lower and upper is an integer from -1000000 to 1000000, and lower <= upper. Inputs satisfy these bounds; missing, nonfinite and reversed-bound values are outside this exercise.
Expected behavior
Count each observation inside its inclusive interval, preserve the number of observations, and return the six-decimal coverage ratio or null for no observations.
Reproduction
{"rows":[{"truth":2,"lower":2,"upper":5},{"truth":5,"lower":2,"upper":5},{"truth":3,"lower":2,"upper":5},{"truth":6,"lower":2,"upper":5}]}{"covered":3,"total":4,"coverage":0.75}{"rows":[{"truth":3,"lower":1,"upper":5},{"truth":0,"lower":1,"upper":5}]}{"covered":1,"total":2,"coverage":0.5}{"rows":[{"truth":4,"lower":4,"upper":4}]}{"covered":1,"total":1,"coverage":1.0}Before you begin
- Comparison operators
- Counting observations
- Prediction intervals
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.