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

Add mean_squared_error functional metric #515

Merged
merged 9 commits into from
Dec 6, 2024
Merged

Add mean_squared_error functional metric #515

merged 9 commits into from
Dec 6, 2024

Conversation

d-a-bunin
Copy link
Collaborator

@d-a-bunin d-a-bunin commented Nov 28, 2024

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

See #512

Closing issues

Closes #512.

@d-a-bunin d-a-bunin self-assigned this Nov 28, 2024
Copy link

github-actions bot commented Nov 28, 2024

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

@github-actions github-actions bot temporarily deployed to pull request November 28, 2024 14:37 Inactive
@github-actions github-actions bot temporarily deployed to pull request November 29, 2024 09:15 Inactive
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.53%. Comparing base (0b1b29d) to head (e701e49).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
etna/metrics/functional_metrics.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #515      +/-   ##
==========================================
+ Coverage   90.42%   90.53%   +0.11%     
==========================================
  Files         247      247              
  Lines       16559    16568       +9     
==========================================
+ Hits        14973    15000      +27     
+ Misses       1586     1568      -18     

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

@@ -41,6 +41,45 @@ def _get_axis_by_multioutput(multioutput: str) -> Optional[int]:
assert_never(multioutput_enum)


def mse_with_missing_handling(y_true: ArrayLike, y_pred: ArrayLike, multioutput: str = "joint") -> ArrayLike:
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 should discuss naming and the fact that sklearn's mse is in our etna/metrics/__init__.py.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can name it mean_squared_error. Mentioning missing handling in the name seems a bit excessive. Better to leave this clarification to the documentation.

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 both mse from sklearn and our mean_squared_error it could be confusing.

We could remove sklearn's version, we haven't mentioned it in our public documentation (but have it in etna/metrics/__init__.py).

I'm also a bit of worried that by replacing sklearn's mse with our mse we changed list of available kwargs.

@github-actions github-actions bot temporarily deployed to pull request December 4, 2024 11:11 Inactive
@github-actions github-actions bot temporarily deployed to pull request December 4, 2024 13:08 Inactive
@d-a-bunin d-a-bunin requested a review from brsnw250 December 5, 2024 07:42
@@ -128,7 +128,7 @@ class Metric(AbstractMetric, BaseMixin):
def __init__(
self,
metric_fn: MetricFunction,
mode: str = MetricAggregationMode.per_segment,
mode: str = MetricAggregationMode.per_segment.value,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should consider setting here a plain string instead of an enum value

Copy link
Collaborator Author

@d-a-bunin d-a-bunin Dec 5, 2024

Choose a reason for hiding this comment

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

You suggest using just "per-segment"? I suppose we should do this in all other places too?

Why do you think we should consider that?

@@ -41,6 +41,45 @@ def _get_axis_by_multioutput(multioutput: str) -> Optional[int]:
assert_never(multioutput_enum)


def mse_with_missing_handling(y_true: ArrayLike, y_pred: ArrayLike, multioutput: str = "joint") -> ArrayLike:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can name it mean_squared_error. Mentioning missing handling in the name seems a bit excessive. Better to leave this clarification to the documentation.

Comment on lines 48 to 49
`Wikipedia entry on the Mean squared error
<https://en.wikipedia.org/wiki/Mean_squared_error>`_
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it is a good idea to reference wikipedia. Better to replace with a more reputable source (e.g. Hyndman Forecasting) or to remove completely.

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 I just repeated that we have done with mape and smape. I could replace link in those places too.

`Wikipedia entry on the Mean squared error
<https://en.wikipedia.org/wiki/Mean_squared_error>`_

The nans are ignored during computation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be helpful to also note what will be returned if all nans in the segment

@github-actions github-actions bot temporarily deployed to pull request December 6, 2024 08:14 Inactive
@d-a-bunin d-a-bunin requested a review from brsnw250 December 6, 2024 08:49
@d-a-bunin d-a-bunin merged commit a7e20f4 into master Dec 6, 2024
17 checks passed
@d-a-bunin d-a-bunin deleted the issue-512 branch December 6, 2024 13:30
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.

Add mean_squared_error functional metric
2 participants