-
Notifications
You must be signed in to change notification settings - Fork 10
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 MissingCounter
metric
#520
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ Scalar metrics: | |
MaxDeviation | ||
MedAE | ||
Sign | ||
MissingCounter | ||
|
||
Interval metrics: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
from etna.metrics.base import Metric | ||
from etna.metrics.base import MetricWithMissingHandling | ||
from etna.metrics.functional_metrics import count_missing_values | ||
from etna.metrics.functional_metrics import mae | ||
from etna.metrics.functional_metrics import mape | ||
from etna.metrics.functional_metrics import max_deviation | ||
|
@@ -417,4 +418,59 @@ def greater_is_better(self) -> bool: | |
return False | ||
|
||
|
||
__all__ = ["MAE", "MSE", "RMSE", "R2", "MSLE", "MAPE", "SMAPE", "MedAE", "Sign", "MaxDeviation", "WAPE"] | ||
class MissingCounter(MetricWithMissingHandling): | ||
"""Missing values counter with multi-segment computation support. | ||
|
||
.. math:: | ||
MissingCounter(y\_true, y\_pred) = \\sum_{i=1}^{n}{isnan(y\_true_i)} | ||
|
||
Notes | ||
----- | ||
You can read more about logic of multi-segment metrics in Metric docs. | ||
""" | ||
|
||
def __init__(self, mode: str = "per-segment", **kwargs): | ||
"""Init metric. | ||
|
||
Parameters | ||
---------- | ||
mode: | ||
"macro" or "per-segment", way to aggregate metric values over segments: | ||
|
||
* if "macro" computes average value | ||
|
||
* if "per-segment" -- does not aggregate metrics | ||
|
||
See :py:class:`~etna.metrics.base.MetricAggregationMode`. | ||
kwargs: | ||
metric's computation arguments | ||
""" | ||
count_missing_values_per_output = partial(count_missing_values, multioutput="raw_values") | ||
super().__init__( | ||
mode=mode, | ||
metric_fn=count_missing_values_per_output, | ||
metric_fn_signature="matrix_to_array", | ||
missing_mode="ignore", | ||
**kwargs, | ||
) | ||
|
||
@property | ||
def greater_is_better(self) -> None: | ||
"""Whether higher metric value is better.""" | ||
return None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is understandable that we can't control missing values in the true target, but shouldn't it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think metrics should be used to compare different methods with each other on the same dataset. This metric will be the same for the same dataset because it doesn't depend on the model. |
||
|
||
|
||
__all__ = [ | ||
"MAE", | ||
"MSE", | ||
"RMSE", | ||
"R2", | ||
"MSLE", | ||
"MAPE", | ||
"SMAPE", | ||
"MedAE", | ||
"Sign", | ||
"MaxDeviation", | ||
"WAPE", | ||
"MissingCounter", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't added it into
etna/metrics/__init__.py
. Do we have to do it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think it is needed there.