Skip to content

Metrics for categorical forecasting #2767

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jonasblanc
Copy link
Collaborator

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 #.

Summary

Implement metrics for categorical forecasting.

TODO:

  • extend list of supported categorical metrics
  • categorical specific tests
  • adapt metrics decorator to support per class score and cross-class averaging

Other Information

@jonasblanc jonasblanc moved this to In progress in darts Apr 10, 2025
@jonasblanc jonasblanc added this to darts Apr 10, 2025
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 74.44444% with 23 lines in your changes missing coverage. Please review.

Project coverage is 95.03%. Comparing base (8e60174) to head (96492e7).

Files with missing lines Patch % Lines
darts/metrics/categorical_metrics.py 74.44% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2767      +/-   ##
==========================================
- Coverage   95.23%   95.03%   -0.21%     
==========================================
  Files         145      146       +1     
  Lines       15092    15182      +90     
==========================================
+ Hits        14373    14428      +55     
- Misses        719      754      +35     

☔ 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.

@jonasblanc jonasblanc self-assigned this Apr 17, 2025
@jonasblanc jonasblanc added feature request Use this label to request a new feature improvement New feature or improvement labels Apr 17, 2025
Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

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

Thanks @jonasblanc, this is a nice start 🚀

Some thoughts:

  • remove per time step metric support for all metrics, except maybe the accuracy itself
  • add support for probabilistic series:
    • if preds are sampled, take the label with highest count
    • if preds are likelihood parameters, take the label with highest probability
  • for a first collection, we should have accuracy, precision, recall, f1
  • if we don't add timeseries support for confusion matrix, etc. then we should make these functions private

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could call it classification.py then it's a bit more nice to import:

from darts.metrics.classification import acc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe forecasting_classification in order not to be confused with up-coming TS classification ?

intersect,
remove_nan_union=False,
)
return np.mean(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here you give already the aggregated value over time. But your metric is defined as a per time step metric since it accepts the time_reduction.

Either you return here the time dependent accuracy (e.g. boolean 1 / 0 whether it's a hit per time step) and add a mean accuracy metric that aggregates (see metrics.ae and metrics.mae as an example), or you call it macc directly and remove the time_reduction.


@multi_ts_support
@multivariate_support
def bacc(
Copy link
Collaborator

Choose a reason for hiding this comment

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

these metrics below should not allow the time_reduction but should always return the aggregated metric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Use this label to request a new feature improvement New feature or improvement
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants