PinballLoss¶
yohou.metrics.PinballLoss
¶
Bases: BaseIntervalScorer
Pinball Loss (Quantile Score) for prediction intervals.
Evaluates quantile forecasts with asymmetric penalty. Each interval bound corresponds to a quantile: lower bound = (1-α)/2, upper bound = (1+α)/2.
The pinball loss for quantile τ is:
For interval forecasts at coverage α, the total pinball loss is the sum of losses for lower (τ=(1-α)/2) and upper (τ=(1+α)/2) bounds.
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 pinball loss (lower is better). |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import PinballLoss
>>> 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]
... })
>>> loss = PinballLoss()
>>> _ = loss.fit(y_true)
>>> loss.score(y_true, y_pred)
0.2...
Notes ¶
- Lower is better
- Penalizes under-prediction differently than over-prediction
- Scale-dependent
- More relevant for quantile regression forecasters
- Useful when asymmetric errors have different costs
See Also ¶
IntervalScore: Symmetric penalty for coverage violationsEmpiricalCoverage: Coverage-only metric
Source Code ¶
Source code in src/yohou/metrics/interval.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
Tutorials¶
The following example notebooks use this component:
-
How to Evaluate Interval Forecasts
Evaluate prediction intervals with EmpiricalCoverage, IntervalScore, MeanIntervalWidth, PinballLoss, and CalibrationError across coverage levels.