IntervalScore¶
yohou.metrics.IntervalScore
¶
Bases: BaseIntervalScorer
Interval Score (Winkler Score) for prediction intervals.
Combines interval width with penalties for observations falling outside the interval. Balances sharpness and coverage in a single metric.
The interval score for coverage rate α is:
where the first term is interval width and the second/third terms are penalties for under/over-coverage.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
aggregation_method
|
list of str or str
|
Dimensions to collapse when aggregating scores. Orthogonal modes:
|
"all"
|
coverage_rates
|
list of float, dict of float to float, or None
|
Coverage rate filter (list) or filter with weights (dict). |
None
|
groups
|
list of str, dict of str to float, or None
|
Panel group filter (list) or filter with weights (dict). |
None
|
components
|
list of str, dict of str to float, or None
|
Component filter (list) or filter with weights (dict). |
None
|
Attributes ¶
| Name | Type | Description |
|---|---|---|
lower_is_better |
bool
|
True for interval score (lower is better). |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import IntervalScore
>>> y_true = pl.DataFrame({"time": [datetime(2020, 1, 1), datetime(2020, 1, 2)], "value": [10.0, 20.0]})
>>> y_pred = pl.DataFrame({
... "vintage_time": [datetime(2019, 12, 31)] * 2,
... "time": [datetime(2020, 1, 1), datetime(2020, 1, 2)],
... "value_lower_0.9": [8.0, 18.0],
... "value_upper_0.9": [12.0, 22.0],
... })
>>> scorer = IntervalScore()
>>> _ = scorer.fit(y_true)
>>> scorer.score(y_true, y_pred)
4.0
Notes ¶
- Lower is better
- Penalizes both wide intervals and poor coverage
- Scale-dependent (same units as target)
- Related to the Winkler score; here
αdenotes the nominal coverage rate, so the penalty denominator is the coverage rate rather than the significance level1 - coverage_rateused in the classical Winkler/interval-score formulation (Gneiting & Raftery 2007) - Widely used in forecasting competitions (M4, M5)
See Also ¶
EmpiricalCoverage: Coverage-only metricMeanIntervalWidth: Width-only metricPinballLoss: Asymmetric quantile-based metric
Source Code ¶
Source code in src/yohou/metrics/interval.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
Tutorials¶
The following example notebooks use this component:
-
Conformal Prediction Intervals
Build distribution-free prediction intervals with SplitConformalForecaster using calibration holdouts and configurable conformity scoring functions.
-
How to Build Interval Forecasts with Reduction
Wrap any quantile-capable sklearn estimator with IntervalReductionForecaster to produce calibrated prediction intervals across multiple horizons.
-
How to Evaluate Interval Forecasts
Evaluate prediction intervals with EmpiricalCoverage, IntervalScore, MeanIntervalWidth, PinballLoss, and CalibrationError across coverage levels.
-
How to Forecast Intervals with CatBoost Multiquantile
Use IntervalReductionForecaster with CatBoost's native multiquantile objective for simultaneous lower and upper bound estimation.
-
How to Search Interval Forecaster Hyperparameters
Tune interval forecaster parameters directly with interval metrics in GridSearchCV, including mixed point+interval multimetric search.
-
How to Use Conformity Scorers
Compare Residual, AbsoluteResidual, GammaResidual, and AbsoluteGammaResidual conformity scorers with coverage/width analysis and DistanceSimilarity interaction.