RootMeanSquaredError¶
yohou.metrics.point.RootMeanSquaredError
¶
Bases: BasePointScorer
Root Mean Squared Error metric for point forecasts.
Computes the square root of the average of squared differences between predictions and actual values. This metric penalizes large errors while maintaining the same units as the target variable, making it more interpretable than MeanSquaredError.
The RMSE is defined as:
where \(y_i\) is the actual value, \(\\hat{y}_i\) is the predicted value, and \(n\) is the number of observations.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
aggregation_method
|
list of str or str
|
Dimensions to aggregate over. Options: - "stepwise": Aggregate across forecasting steps. - "vintagewise": Aggregate across vintages (observed times). - "componentwise": Aggregate across components, return per-timestep DataFrame - "groupwise": Aggregate across panel groups (panel data only) - "all": Aggregate across all dimensions (returns scalar). Same as ["stepwise", "vintagewise", "componentwise", "groupwise"]. Example outputs: - ["stepwise", "vintagewise"]: Per-component (and per-group) DataFrame. - "componentwise" or ["componentwise"]: Per-timestep (and per-group) DataFrame. - "groupwise" or ["groupwise"]: Per-component per-timestep DataFrame (panel aggregated). - ["stepwise", "vintagewise", "componentwise"]: Scalar (global) or per-group DataFrame (panel). - "all": Scalar float (hierarchically aggregated for panel data). |
"all"
|
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
|
Always True for MSE. |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import RootMeanSquaredError
>>> 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": [12.0, 19.0, 28.0],
... })
>>> rmse = RootMeanSquaredError()
>>> _ = rmse.fit(y_true)
>>> rmse.score(y_true, y_pred)
1.732...
Notes¶
- RMSE is the square root of MSE, providing errors in original units
- More sensitive to outliers compared to MeanAbsoluteError but less than MSE
- Commonly used when large errors are particularly undesirable
- Interpretable in the same units as the target variable
See Also¶
MeanAbsoluteError: Mean Absolute Error, less sensitive to outliersMeanSquaredError: Mean Squared Error, RMSE squaredRootMeanSquaredScaledError: Root Mean Squared Scaled Error, scale-independent version
Source Code¶
Show/Hide source
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 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |