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/show_anomalies for multivariate #2544

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co
**Improved**

- New model: `StatsForecastAutoTBATS`. This model offers the [AutoTBATS](https://nixtlaverse.nixtla.io/statsforecast/src/core/models.html#autotbats) model from Nixtla's `statsforecasts` library. [#2611](https://github.com/unit8co/darts/pull/2611) by [He Weilin](https://github.com/cnhwl).
- Added `multivariate_plot` parameter in `show_anomalies()` to separately plot each component in multivariate series. [#2544](https://github.com/unit8co/darts/pull/2544) by [He Weilin](https://github.com/cnhwl).

**Fixed**
- Fixed a bug when performing optimized historical forecasts with `stride=1` using a `RegressionModel` with `output_chunk_shift>=1` and `output_chunk_length=1`, where the forecast time index was not properly shifted. [#2634](https://github.com/unit8co/darts/pull/2634) by [Mattias De Charleroy](https://github.com/MattiasDC).
Expand Down
4 changes: 4 additions & 0 deletions darts/ad/anomaly_model/anomaly_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def show_anomalies(
names_of_scorers: Union[str, Sequence[str]] = None,
title: str = None,
metric: Optional[Literal["AUC_ROC", "AUC_PR"]] = None,
multivariate_plot: bool = False,
cnhwl marked this conversation as resolved.
Show resolved Hide resolved
**score_kwargs,
):
"""Plot the results of the anomaly model.
Expand Down Expand Up @@ -283,6 +284,8 @@ def show_anomalies(
Default: "AUC_ROC".
score_kwargs
parameters for the `score()` method.
multivariate_plot
If True, it will separately plot each component in multivariate series.
"""
series = _check_input(series, name="series", num_series_expected=1)[0]
predict_kwargs = predict_kwargs if predict_kwargs is not None else {}
Expand Down Expand Up @@ -310,6 +313,7 @@ def show_anomalies(
names_of_scorers=names_of_scorers,
title=title,
metric=metric,
multivariate_plot=multivariate_plot,
)

@property
Expand Down
4 changes: 4 additions & 0 deletions darts/ad/anomaly_model/forecasting_am.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def show_anomalies(
names_of_scorers: Union[str, Sequence[str]] = None,
title: str = None,
metric: Optional[Literal["AUC_ROC", "AUC_PR"]] = None,
multivariate_plot: bool = False,
cnhwl marked this conversation as resolved.
Show resolved Hide resolved
**score_kwargs,
):
"""Plot the results of the anomaly model.
Expand Down Expand Up @@ -506,6 +507,8 @@ def show_anomalies(
Optionally, the name of the metric function to use. Must be one of "AUC_ROC" (Area Under the
Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
Default: "AUC_ROC".
multivariate_plot
If True, it will separately plot each component in multivariate series.
score_kwargs
parameters for the `score()` method.
"""
Expand All @@ -527,6 +530,7 @@ def show_anomalies(
names_of_scorers=names_of_scorers,
title=title,
metric=metric,
multivariate_plot=multivariate_plot,
**score_kwargs,
)

Expand Down
6 changes: 6 additions & 0 deletions darts/ad/scorers/scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def show_anomalies_from_prediction(
anomalies: TimeSeries = None,
title: str = None,
metric: Optional[Literal["AUC_ROC", "AUC_PR"]] = None,
multivariate_plot: bool = False,
cnhwl marked this conversation as resolved.
Show resolved Hide resolved
):
"""Plot the results of the scorer.

Expand Down Expand Up @@ -208,6 +209,8 @@ def show_anomalies_from_prediction(
Optionally, the name of the metric function to use. Must be one of "AUC_ROC" (Area Under the
Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
Default: "AUC_ROC".
multivariate_plot
If True, it will separately plot each component in multivariate series.
"""
series = _check_input(series, name="series", num_series_expected=1)[0]
pred_series = _check_input(
Expand All @@ -230,6 +233,7 @@ def show_anomalies_from_prediction(
names_of_scorers=scorer_name,
title=title,
metric=metric,
multivariate_plot=multivariate_plot,
)

@property
Expand Down Expand Up @@ -580,6 +584,7 @@ def show_anomalies(
scorer_name: str = None,
title: str = None,
metric: Optional[Literal["AUC_ROC", "AUC_PR"]] = None,
multivariate_plot: bool = False,
):
"""Plot the results of the scorer.

Expand Down Expand Up @@ -633,6 +638,7 @@ def show_anomalies(
names_of_scorers=scorer_name,
title=title,
metric=metric,
multivariate_plot=multivariate_plot,
)

@property
Expand Down
Loading
Loading