Skip to content
svgcoverage-by-horizon

Coverage by horizon

Do prediction intervals keep their promise further ahead?

Demo data · seed 20261101 · 24 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read each line as an interval's actual coverage at each horizon.
  2. Compare with its dashed nominal level.
  3. Lines falling below their target mean the intervals are too narrow that far ahead.

Watch out

  • Long horizons have fewer backtest values, so their coverage is more uncertain.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Coverage is scored on the backtest's forecasts by the host (cs-ml backtest.rs).
  • Each point uses only the forecasts at that horizon, so few origins make it coarse: with 5 origins, each point moves in steps of 20%.
# Coverage by horizon — Codesplash Chart Lab (recipe "coverage-by-horizon")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("coverage-by-horizon-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
H = "h"
LEVEL = "level"
COV = "coverage"
d = df.dropna(subset=[H, LEVEL, COV])
fig, ax = plt.subplots(figsize=(8, 4.2))
for i, (level, s) in enumerate(sorted(d.groupby(LEVEL), key=lambda kv: -kv[0])):
    s = s.sort_values(H)
    colour = PALETTE[i % len(PALETTE)]
    ax.plot(s[H], s[COV], marker="o", color=colour, label=f"{level:g}%")
    ax.axhline(level / 100, color=colour, alpha=0.45, linestyle="--")
ax.set_ylim(0, 1)
ax.set_xlabel("steps ahead")
ax.set_ylabel("share of actuals inside the interval")
ax.legend(fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads coverage-by-horizon-demo.csv · app theme from the optional codesplash helper