EmpiricalCoverage¶
yohou.metrics.interval.EmpiricalCoverage
¶
Bases: BaseIntervalScorer
Empirical coverage rate for prediction intervals.
Measures the proportion of true values falling within the predicted intervals. A well-calibrated forecaster should achieve coverage close to the nominal rate (e.g., 90% for α=0.9).
The empirical coverage for a given coverage rate α is:
where \(L_i(\\alpha)\) and \(U_i(\\alpha)\) are the lower and upper bounds at coverage \(\\alpha\), \(\\mathbb{1}(\\cdot)\) is the indicator function, and \(n\) is the number of observations.
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
|
False for coverage (deviations from nominal rate in either direction are bad). |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import EmpiricalCoverage
>>> y_true = pl.DataFrame({
... "time": [datetime(2020, 1, 1), datetime(2020, 1, 2), datetime(2020, 1, 3)],
... "value": [10.0, 20.0, 30.0],
... })
>>> y_pred = pl.DataFrame({
... "vintage_time": [datetime(2019, 12, 31)] * 3,
... "time": [datetime(2020, 1, 1), datetime(2020, 1, 2), datetime(2020, 1, 3)],
... "value_lower_0.9": [8.0, 18.0, 28.0],
... "value_upper_0.9": [12.0, 22.0, 32.0],
... })
>>> coverage = EmpiricalCoverage()
>>> _ = coverage.fit(y_true)
>>> coverage.score(y_true, y_pred)
1.0
Notes¶
- Perfect coverage = nominal rate (e.g., 0.9 for 90% intervals)
- Over-coverage (> nominal) indicates conservative (wide) intervals
- Under-coverage (< nominal) indicates poor calibration
- Missing values are excluded from computation
See Also¶
MeanIntervalWidth: Evaluates interval sharpnessIntervalScore: Combined coverage and sharpness metricCalibrationError: Aggregate miscalibration metric
Source Code¶
Show/Hide source
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
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 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.
-
Interval Forecasting
Getting-Started
Wrap a point forecaster with SplitConformalForecaster to produce 95% prediction intervals with statistical coverage guarantees.