Commit c4f5aac
[BUG] Safe fallback for retrieving index from
References : Fixes #2255
## Description
If a user creates an instance of `QuantileLoss` defining bounding target
quantiles (e.g., `[0.1, 0.9]`) but excluding the direct median
probability `0.5`, performing a `.to_prediction()` pass crashes parsing
the output.
## Changes Made
- Introduced a conditional flow handling. It first checks `if 0.5 in
self.quantiles`, returning exact. If absent, it establishes the minimum
offset matching `0.5`, safely reverting to the closest approximated
center. Modified `pytorch_forecasting/metrics/quantile.py`.
CC : @phoeenniixx , @PranavBhatP , @fkiraly
---------
Co-authored-by: Aryan Saini <116151399+phoeenniixx@users.noreply.github.com>
Co-authored-by: Felix Hirwa Nshuti <hirwanshutiflx@gmail.com>
Co-authored-by: Franz Király <fkiraly@gcos.ai>QuantileLoss.to_prediction when 0.5 is unavailable (#2256)1 parent 4d8d97c commit c4f5aac
2 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
570 | 571 | | |
571 | 572 | | |
572 | 573 | | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
0 commit comments