Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/metrics quantiles #2530

Merged
merged 21 commits into from
Sep 20, 2024
Merged

Feat/metrics quantiles #2530

merged 21 commits into from
Sep 20, 2024

Conversation

dennisbader
Copy link
Collaborator

@dennisbader dennisbader commented Sep 14, 2024

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #2527.

Summary

  • adds support for computing metrics on one or multiple quantiles q, either from probabilistic predictions or predicted quantiles.
  • adds support for computing backtest and residuals on these quantile metrics
  • added property TimeSeries.shape to get the shape of the time series
  • adds first interval metrics: miw (Mean Interval Width, time aggregated) and iw (Interval Width, per time step / non-aggregated) which compute the width of quantile intervals q_intervals (expected to be a tuple or sequence of tuples with (lower quantile, upper quantile).

Copy link

codecov bot commented Sep 15, 2024

Codecov Report

Attention: Patch coverage is 98.63014% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.84%. Comparing base (67d4dbd) to head (b1f7825).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
darts/metrics/metrics.py 98.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2530      +/-   ##
==========================================
+ Coverage   93.77%   93.84%   +0.07%     
==========================================
  Files         139      139              
  Lines       14765    14841      +76     
==========================================
+ Hits        13846    13928      +82     
+ Misses        919      913       -6     

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

Copy link
Collaborator

@madtoinou madtoinou left a comment

Choose a reason for hiding this comment

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

Nice job, I can feel the conformal prediction getting closer and closer...

Some comments to simplify a bit some part of the code, also asking for some clarification.

darts/metrics/metrics.py Show resolved Hide resolved
darts/metrics/metrics.py Show resolved Hide resolved
raise_log(
ValueError(
"Metric output must have 1 dimension for aggregated metrics (e.g. `mae()`, ...), "
"or 2 dimension for time dependent metrics (e.g. `ae()`, ...)"
),
logger=logger,
)
elif len(vals.shape) == 1:
elif len(vals.shape) == 2:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we assume that the case vals.shape == 1 can never happen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could assume that the if it's 1dim then it must be the components axis. But I wonder it's better to raise more errors here to make sure we actually get the expected shapes 🤔

darts/metrics/metrics.py Outdated Show resolved Hide resolved
darts/metrics/metrics.py Outdated Show resolved Hide resolved
darts/tests/models/forecasting/test_residuals.py Outdated Show resolved Hide resolved
darts/tests/models/forecasting/test_residuals.py Outdated Show resolved Hide resolved
darts/tests/models/forecasting/test_residuals.py Outdated Show resolved Hide resolved
darts/utils/utils.py Show resolved Hide resolved
Copy link
Collaborator

@madtoinou madtoinou left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@dennisbader dennisbader merged commit b41be28 into master Sep 20, 2024
9 checks passed
@dennisbader dennisbader deleted the feat/metrics_quantiles branch September 20, 2024 16:29
eschibli pushed a commit to eschibli/darts that referenced this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compute multiple quantiles for Metrics
2 participants