Skip to content

[BUG] Safe fallback for retrieving index from QuantileLoss.to_prediction when 0.5 is unavailable#2256

Open
Muhammad-Rebaal wants to merge 6 commits into
sktime:mainfrom
Muhammad-Rebaal:quantile-loss-missing-median
Open

[BUG] Safe fallback for retrieving index from QuantileLoss.to_prediction when 0.5 is unavailable#2256
Muhammad-Rebaal wants to merge 6 commits into
sktime:mainfrom
Muhammad-Rebaal:quantile-loss-missing-median

Conversation

@Muhammad-Rebaal
Copy link
Copy Markdown
Contributor

References : #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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@44e3ef2). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2256   +/-   ##
=======================================
  Coverage        ?   86.93%           
=======================================
  Files           ?      166           
  Lines           ?     9767           
  Branches        ?        0           
=======================================
  Hits            ?     8491           
  Misses          ?     1276           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.93% <100.00%> (?)
pytest 86.93% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@phoeenniixx phoeenniixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Can you please add a minimal test to make sure it is working as expected?

@phoeenniixx phoeenniixx added the bug Something isn't working label Apr 11, 2026
@phoeenniixx phoeenniixx changed the title [Bug] Safe fallback for retrieving index from QuantileLoss.to_prediction when 0.5 is unavailable [BUG] Safe fallback for retrieving index from QuantileLoss.to_prediction when 0.5 is unavailable Apr 11, 2026
@Muhammad-Rebaal
Copy link
Copy Markdown
Contributor Author

Hi @phoeenniixx ,
Can you please re-run the failed job HTTP 504 Gateway Time-out when trying to download the stallion.parquet dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants