Skip to content

Commit

Permalink
Merge branch 'master' into feature/title-as-parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathankoch99 authored Jan 8, 2025
2 parents 435de60 + 5bc1960 commit 385ae5f
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co

- 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 the `title` attribute to `TimeSeries.plot()`. This allows to set a title for the plot. [#2639](https://github.com/unit8co/darts/pull/2639) by [Jonathan Koch](https://github.com/jonathankoch99).
- Added parameter `component_wise` to `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,
component_wise: bool = False,
**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.
component_wise
If True, will separately plot each component in case of multivariate anomaly detection.
"""
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,
component_wise=component_wise,
)

@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,
component_wise: bool = False,
**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".
component_wise
If True, will separately plot each component in case of multivariate anomaly detection.
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,
component_wise=component_wise,
**score_kwargs,
)

Expand Down
8 changes: 8 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,
component_wise: bool = False,
):
"""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".
component_wise
If True, will separately plot each component in case of multivariate anomaly detection.
"""
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,
component_wise=component_wise,
)

@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,
component_wise: bool = False,
):
"""Plot the results of the scorer.
Expand Down Expand Up @@ -610,6 +615,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".
component_wise
If True, will separately plot each component in case of multivariate anomaly detection.
"""
series = _check_input(series, name="series", num_series_expected=1)[0]
pred_scores = self.score(series)
Expand All @@ -633,6 +640,7 @@ def show_anomalies(
names_of_scorers=scorer_name,
title=title,
metric=metric,
component_wise=component_wise,
)

@property
Expand Down
Loading

0 comments on commit 385ae5f

Please sign in to comment.