bugger.
All challenges/Pythoneasygsoc-sktime-interval-coverage-v1
THE INVESTIGATION

The forecast interval that excludes its edges

An empirical coverage metric undercounts correct forecasts when the observed value equals an interval endpoint.

MLUpstream bugssktimeForecast evaluation

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

01 Both endpoints are covered observations
{"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}
02 Ordinary interior and exterior observations
{"rows":[{"truth":3,"lower":1,"upper":5},{"truth":0,"lower":1,"upper":5}]}
{"covered":1,"total":2,"coverage":0.5}
03 A zero-width interval covers its exact value
{"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.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.