MeanIntervalWidth¶
yohou.metrics.interval.MeanIntervalWidth
¶
Bases: BaseIntervalScorer
Mean width of prediction intervals.
Measures the average width of prediction intervals. Narrower intervals are preferred (more informative), provided coverage is maintained.
The mean interval width for coverage rate α is:
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 width (narrower intervals are better). |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import MeanIntervalWidth
>>> 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],
... })
>>> width = MeanIntervalWidth()
>>> _ = width.fit(y_true)
>>> width.score(y_true, y_pred)
4.0
Notes¶
- Lower is better (sharper, more precise predictions)
- Should only be compared when coverage is approximately equal
- Scale-dependent (units match target variable)
- Missing values are excluded from computation
- Uses absolute width to handle bound inversions silently
See Also¶
EmpiricalCoverage: Evaluates interval calibrationIntervalScore: Combined coverage and sharpness metric
Source Code¶
Show/Hide source
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
Tutorials¶
The following example notebooks use this component:
-
How to Use Conformity Scorers
Evaluation-Search
Compare Residual, AbsoluteResidual, GammaResidual, and AbsoluteGammaResidual conformity scorers with coverage/width analysis and DistanceSimilarity interaction.
-
How to Evaluate Interval Forecasts
Evaluation-Search
Evaluate prediction intervals with EmpiricalCoverage, IntervalScore, MeanIntervalWidth, PinballLoss, and CalibrationError across coverage levels.
-
How to Search Interval Forecaster Hyperparameters
Evaluation-Search
Tune interval forecaster parameters directly with interval metrics in GridSearchCV, including mixed point+interval multimetric search.
-
How to Forecast Intervals with CatBoost Multiquantile
Forecasting-Models
Use IntervalReductionForecaster with CatBoost's native multiquantile objective for simultaneous lower and upper bound estimation.
-
How to Use Distance-Based Similarity for Intervals
Forecasting-Models
Adaptive prediction intervals via similarity-weighted conformal prediction using DistanceSimilarity with configurable distance metrics and bandwidths.
-
How to Build Interval Forecasts with Reduction
Forecasting-Models
Wrap any quantile-capable sklearn estimator with IntervalReductionForecaster to produce calibrated prediction intervals across multiple horizons.
-
Conformal Prediction Intervals
Getting-Started
Build distribution-free prediction intervals with SplitConformalForecaster using calibration holdouts and configurable conformity scoring functions.
-
How to Create a Custom Interval Forecaster
Getting-Started
Implement a NaiveIntervalForecaster from scratch, validate it with the check generator, and compare it against SplitConformalForecaster.