AbsoluteResidual¶
yohou.metrics.conformity.AbsoluteResidual
¶
Bases: Residual
Absolute residual conformity scorer using unsigned prediction errors.
Computes conformity scores as the absolute difference between true and predicted values:
The absolute residuals produce symmetric prediction intervals, where the lower and upper bounds are equidistant from the point prediction.
See Also¶
Residual: Asymmetric variant using signed residuals.AbsoluteGammaResidual: Scale-dependent symmetric variant.
Examples¶
>>> import polars as pl
>>> from datetime import date
>>> from yohou.metrics.conformity import AbsoluteResidual
>>> scorer = AbsoluteResidual().fit(
... pl.DataFrame({"time": [date(2020, 1, 1), date(2020, 1, 2)], "y": [1.0, 2.0]})
... )
>>> y_truth = pl.DataFrame({"time": [date(2020, 1, 3), date(2020, 1, 4)], "y": [3.0, 5.0]})
>>> y_pred = pl.DataFrame({"time": [date(2020, 1, 3), date(2020, 1, 4)], "y": [2.5, 6.0]})
>>> scores = scorer.score(y_truth, y_pred)
>>> scores.drop("time").to_series().to_list()
[0.5, 1.0]
Source Code¶
Show/Hide source
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 198 199 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 | |
Methods¶
__sklearn_tags__()
¶
score(y_truth, y_pred, /, **score_params)
¶
Compute absolute residual conformity scores.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
y_truth
|
DataFrame
|
True target values. |
required |
y_pred
|
DataFrame
|
Predicted values. |
required |
Returns¶
| Type | Description |
|---|---|
DataFrame
|
Conformity scores (|y_truth - y_pred|) with "time" column preserved. |
Source Code¶
Show/Hide source
inverse_score(y_pred, conformity_scores, coverage_rate)
¶
Construct symmetric prediction intervals from absolute conformity scores.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
y_pred
|
DataFrame
|
Point predictions, optionally with "time" column. |
required |
conformity_scores
|
DataFrame
|
Absolute conformity scores from calibration set, optionally with "time" column. |
required |
coverage_rate
|
float
|
Desired coverage probability. |
required |
Returns¶
| Type | Description |
|---|---|
DataFrame
|
Symmetric prediction intervals. |
Source Code¶
Show/Hide source
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 Search Interval Forecaster Hyperparameters
Evaluation-Search
Tune interval forecaster parameters directly with interval metrics in GridSearchCV, including mixed point+interval multimetric search.
-
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.
-
Conformal Prediction Intervals
Getting-Started
Build distribution-free prediction intervals with SplitConformalForecaster using calibration holdouts and configurable conformity scoring functions.