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

Update interval metrics to work with arbitrary interval bounds #113

Merged
merged 8 commits into from Oct 17, 2023

Conversation

brsnw250
Copy link
Collaborator

@brsnw250 brsnw250 commented Oct 16, 2023

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Proposed Changes

Closing issues

closes #102

@brsnw250 brsnw250 self-assigned this Oct 16, 2023
@github-actions
Copy link

github-actions bot commented Oct 16, 2023

🚀 Deployed on https://deploy-preview-113--etna-docs.netlify.app

@github-actions github-actions bot temporarily deployed to pull request October 16, 2023 12:19 Inactive
@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (71d1ae5) 89.21% compared to head (8dfe7d1) 89.24%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   89.21%   89.24%   +0.03%     
==========================================
  Files         195      195              
  Lines       12615    12657      +42     
==========================================
+ Hits        11254    11296      +42     
  Misses       1361     1361              
Files Coverage Δ
etna/metrics/intervals_metrics.py 99.02% <100.00%> (+0.66%) ⬆️

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

@github-actions github-actions bot temporarily deployed to pull request October 16, 2023 13:32 Inactive
@github-actions github-actions bot temporarily deployed to pull request October 16, 2023 14:17 Inactive
@brsnw250 brsnw250 marked this pull request as ready for review October 17, 2023 07:09

borders_set = {upper_name, lower_name}
borders_presented = len(borders_set & ts_intervals) == len(borders_set)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not borders_presented = len(borders_set & ts_intervals) > 0?
What kind of special cases are handled by your code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we have only one of several borders that are presented in the dataset, in that case we pass check, that you sudgesting. Basically, we check here that all provided border names are in the dataset. I think it is more convenient to use issubset method here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will you rewrite this with issubset?

super().__init__(mode=mode, metric_fn=dummy, **kwargs)
self.quantiles = quantiles
self.quantiles = sorted(quantiles)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we want, for example, add validation that len(quantiles) == 2? Or may be make a warning otherwise.

We could also deprecate quantiles parameter for version 3.0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here we have strictly typed that tuple with 2 elements is expected. But we can add a check with error if size of tuple is different.

Will add deprecation of the parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add the check of the size. Otherwise it can be misleading for the user, I think.

return ts_train, ts_test


@pytest.fixture()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove parentheses.

((0.025, 0.975), "target_0.025", "target_0.975"),
((), "target_0.025", "target_0.975"),
((), "target_lower", "target_upper"),
((0.1, 0.9), "target_lower", "target_upper"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is this test case working? As I understood, there are only lower, upper, 0.025 and 0.975 columns.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, here we just try different ways to select interval.

  1. select the same interval with different methods
  2. disable quantiles and use border names to select quantiles
  3. disable quantiles and use border names to select other interval
  4. quantiles point to non-existing interval, but names point to correct

This fixture contains both sets of intervals. It is done to simplify testing procedure, but somewhat artificial.

@github-actions github-actions bot temporarily deployed to pull request October 17, 2023 13:33 Inactive

class Coverage(Metric, _QuantileMetricMixin):
quantiles_set = {f"target_{quantile:.4g}" for quantile in quantiles}
quantiles_presented = len(quantiles_set & ts_intervals) == len(quantiles_set)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we make this with issubset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, fixed it

Copy link
Collaborator

@d-a-bunin d-a-bunin left a comment

Choose a reason for hiding this comment

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

Look at the question above.

@github-actions github-actions bot temporarily deployed to pull request October 17, 2023 14:26 Inactive
@brsnw250 brsnw250 merged commit f9e1f11 into master Oct 17, 2023
16 checks passed
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.

Update interval metrics to work with arbitrary interval bounds
2 participants