Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
52 changes: 22 additions & 30 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ fledged anomaly detection models.
* [API Reference](https://unit8co.github.io/darts/generated_api/darts.html)
* [Examples](https://unit8co.github.io/darts/examples.html)

##### High Level Introductions
### High Level Introductions
* [Introductory Blog Post](https://medium.com/unit8-machine-learning-publication/darts-time-series-made-easy-in-python-5ac2947a8878)
* [Introduction video (25 minutes)](https://youtu.be/g6OXDnXEtFA)

##### Articles on Selected Topics
### Articles on Selected Topics
* [Training Models on Multiple Time Series](https://medium.com/unit8-machine-learning-publication/training-forecasting-models-on-multiple-time-series-with-darts-dc4be70b1844)
* [Using Past and Future Covariates](https://medium.com/unit8-machine-learning-publication/time-series-forecasting-using-past-and-future-external-data-with-darts-1f0539585993)
* [Temporal Convolutional Networks and Forecasting](https://medium.com/unit8-machine-learning-publication/temporal-convolutional-networks-and-forecasting-5ce1b6e97ce4)
Expand Down Expand Up @@ -83,6 +83,7 @@ train, val = series[:-36], series[-36:]
```

Fit an exponential smoothing model, and make a (probabilistic) prediction over the validation series' duration:

```python
from darts.models import ExponentialSmoothing

Expand All @@ -92,6 +93,7 @@ prediction = model.predict(len(val), num_samples=1000)
```

Plot the median, 5th and 95th percentiles:

```python
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -235,7 +237,7 @@ Here's a breakdown of the forecasting models currently implemented in Darts. Our
| [ARIMA](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.arima.html#darts.models.forecasting.arima.ARIMA) | | ✅ 🔴 | 🔴 ✅ 🔴 | ✅ 🔴 | 🔴 |
| [VARIMA](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.varima.html#darts.models.forecasting.varima.VARIMA) | | 🔴 ✅ | 🔴 ✅ 🔴 | ✅ 🔴 | 🔴 |
| [ExponentialSmoothing](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.exponential_smoothing.html#darts.models.forecasting.exponential_smoothing.ExponentialSmoothing) | | ✅ 🔴 | 🔴 🔴 🔴 | ✅ 🔴 | 🔴 |
| [Theta](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.theta.html#darts.models.forecasting.theta.Theta) and [FourTheta](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.theta.html#darts.models.forecasting.theta.FourTheta) | [Theta](https://robjhyndman.com/papers/Theta.pdf) & [4 Theta](https://github.com/Mcompetitions/M4-methods/blob/master/4Theta%20method.R) | ✅ 🔴 | 🔴 🔴 🔴 | 🔴 🔴 | 🔴 |
| [Theta](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.theta.html#darts.models.forecasting.theta.Theta) and [FourTheta](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.theta.html#darts.models.forecasting.theta.FourTheta) | [Theta paper](https://robjhyndman.com/papers/Theta.pdf) & [4 Theta source](https://github.com/Mcompetitions/M4-methods/blob/master/4Theta%20method.R) | ✅ 🔴 | 🔴 🔴 🔴 | 🔴 🔴 | 🔴 |
| [Prophet](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.prophet_model.html#darts.models.forecasting.prophet_model.Prophet) | [Prophet repo](https://github.com/facebook/prophet) | ✅ 🔴 | 🔴 ✅ 🔴 | ✅ 🔴 | 🔴 |
| [FFT](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.fft.html#darts.models.forecasting.fft.FFT) (Fast Fourier Transform) | | ✅ 🔴 | 🔴 🔴 🔴 | 🔴 🔴 | 🔴 |
| [KalmanForecaster](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.kalman_forecaster.html#darts.models.forecasting.kalman_forecaster.KalmanForecaster) using the Kalman filter and N4SID for system identification | [N4SID paper](https://people.duke.edu/~hpgavin/SystemID/References/VanOverschee-Automatica-1994.pdf) | ✅ ✅ | 🔴 ✅ 🔴 | ✅ 🔴 | 🔴 |
Expand Down
8 changes: 4 additions & 4 deletions darts/ad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
A suite of tools for performing anomaly detection and classification
on time series.
- `Anomaly Scorers <https://unit8co.github.io/darts/generated_api/darts.ad.scorers.html>`_ are at the core of the
- `Anomaly Scorers <https://unit8co.github.io/darts/generated_api/darts.ad.scorers.html>`__ are at the core of the
anomaly detection module. They produce anomaly scores time series, either for single series (`score()`),
or for series accompanied by some predictions (`score_from_prediction()`). Scorers can be trainable
(e.g., :class:`~darts.ad.scorers.kmeans_scorer.KMeansScorer`) or not
(e.g., :class:`~darts.ad.scorers.norm_scorer.NormScorer`).
- `Anomaly Models <https://unit8co.github.io/darts/generated_api/darts.ad.anomaly_model.html>`_ offer a convenient way
- `Anomaly Models <https://unit8co.github.io/darts/generated_api/darts.ad.anomaly_model.html>`__ offer a convenient way
to produce anomaly scores from any of Darts forecasting models
(:class:`~darts.ad.anomaly_model.forecasting_am.ForecastingAnomalyModel`) or filtering models
(:class:`~darts.ad.anomaly_model.filtering_am.FilteringAnomalyModel`), by comparing models' predictions with actual
observations. These classes take as parameters one Darts model, and one or multiple scorers, and can be readily used
to produce anomaly scores with the `score()` method.
- `Anomaly Detectors <https://unit8co.github.io/darts/generated_api/darts.ad.detectors.html>`_: transform raw time
- `Anomaly Detectors <https://unit8co.github.io/darts/generated_api/darts.ad.detectors.html>`__: transform raw time
series (such as anomaly scores) into binary anomaly time series.
- `Anomaly Aggregators <https://unit8co.github.io/darts/generated_api/darts.ad.aggregators.html>`_: combine multiple
- `Anomaly Aggregators <https://unit8co.github.io/darts/generated_api/darts.ad.aggregators.html>`__: combine multiple
binary anomaly time series (in the form of multivariate time series) into a single binary anomaly time series
applying boolean logic.
"""
Expand Down
3 changes: 2 additions & 1 deletion darts/ad/aggregators/aggregators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Anomaly aggregators base classes
Base Aggregator
---------------
"""

# TODO:
Expand Down
2 changes: 1 addition & 1 deletion darts/ad/aggregators/ensemble_sklearn_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, model: BaseEnsemble) -> None:
"""Ensemble scikit-learn aggregator

Aggregator wrapped around the sklearn ensemble model `sklearn ensemble model
<https://scikit-learn.org/stable/modules/ensemble.html>`_.
<https://scikit-learn.org/stable/modules/ensemble.html>`__.

Parameters
----------
Expand Down
3 changes: 2 additions & 1 deletion darts/ad/anomaly_model/anomaly_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Anomaly models base classes
Base Anomaly Model
------------------
"""

import sys
Expand Down
3 changes: 2 additions & 1 deletion darts/ad/detectors/detectors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Detector Base Classes
Base Detector
-------------
"""

# TODO:
Expand Down
2 changes: 1 addition & 1 deletion darts/ad/detectors/iqr_detector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Interquartile Range (IQR) Detector
-----------------
----------------------------------

Flags anomalies that are beyond the IQR (between the third and the first quartile)
of historical data by some factor of it's difference (typically 1.5).
Expand Down
2 changes: 1 addition & 1 deletion darts/ad/scorers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
prediction (coming e.g., from a forecasting model) and the series itself. When scoring, the scorer will attribute a
higher score to residuals that are distant from the clusters found during the training phase.

Note that `Anomaly Models <https://unit8co.github.io/darts/generated_api/darts.ad.anomaly_model.html>`_
Note that `Anomaly Models <https://unit8co.github.io/darts/generated_api/darts.ad.anomaly_model.html>`__
can be used to conveniently combine any of Darts forecasting and filtering models with one or multiple scorers.

Most of the scorers have the following main parameters:
Expand Down
4 changes: 2 additions & 2 deletions darts/ad/scorers/pyod_scorer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
PyOD Scorer
-----
-----------

This scorer can wrap around detection algorithms of PyOD.
`PyOD https://pyod.readthedocs.io/en/latest/#`_.
`PyOD <https://pyod.readthedocs.io/en/latest/>`__.
"""

import numpy as np
Expand Down
19 changes: 11 additions & 8 deletions darts/ad/scorers/scorers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Scorers Base Classes
Base Scorer
-----------
"""

# TODO:
Expand Down Expand Up @@ -592,15 +593,17 @@ def show_anomalies(
Computes the score on the given series input. And plots the results.

The plot will be composed of the following:
- the series itself.
- the anomaly score of the score.
- the actual anomalies, if given.

- the series itself.
- the anomaly score of the score.
- the actual anomalies, if given.

It is possible to:
- add a title to the figure with the parameter `title`
- give personalized name to the scorer with `scorer_name`
- show the results of a metric for the anomaly score (AUC_ROC or AUC_PR),
if the actual anomalies is provided.

- add a title to the figure with the parameter `title`
- give personalized name to the scorer with `scorer_name`
- show the results of a metric for the anomaly score (AUC_ROC or AUC_PR),
if the actual anomalies is provided.

Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions darts/ad/scorers/wasserstein_scorer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Wasserstein Scorer
-----
------------------

Wasserstein Scorer (distance function defined between probability distributions) [1]_.
The implementations is wrapped around `scipy.stats
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.wasserstein_distance.html>`_.
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.wasserstein_distance.html>`__.

References
----------
Expand Down
5 changes: 5 additions & 0 deletions darts/dataprocessing/dtw/cost_matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
DTW Cost Matrix
---------------
"""

import array
from abc import ABC, abstractmethod
from itertools import repeat
Expand Down
6 changes: 0 additions & 6 deletions darts/dataprocessing/dtw/dtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ class DTWAlignment:
The `CostMatrix` for DTW.
"""

n: int
m: int
series1: TimeSeries
series2: TimeSeries
cost: CostMatrix

def __init__(self, series1: TimeSeries, series2: TimeSeries, cost: CostMatrix):
self.n = len(series1)
self.m = len(series2)
Expand Down
27 changes: 14 additions & 13 deletions darts/dataprocessing/encoders/encoder_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,20 @@ def __init__(
scenarios described below. With user `covariates`, it simply copies and returns the `covariates` time index.

It can be used:
A in combination with :class:`LocalForecastingModel`, or in a model agnostic scenario:
All parameters can be ignored. This scenario is only supported by
:class:`FutureCovariatesIndexGenerator`.
B in combination with :class:`SKLearnModel`:
Set `input_chunk_length`, `output_chunk_length`, and `lags_covariates`.
`input_chunk_length` is the absolute value of the minimum target lag `abs(min(lags))` used with the
`SKLearnModel`.
Set `output_chunk_length`, and `lags_covariates` with the identical values used at forecasting model
creation. For the covariates lags, use `lags_past_covariates` for class:`PastCovariatesIndexGenerator`,
and `lags_future_covariates` for class:`PastCovariatesIndexGenerator`.
C in combination with :class:`TorchForecastingModel`:
Set `input_chunk_length`, and `output_chunk_length` with the identical values used at forecasting model
creation.

- in combination with :class:`LocalForecastingModel`, or in a model agnostic scenario:
All parameters can be ignored. This scenario is only supported by
:class:`FutureCovariatesIndexGenerator`.
- in combination with :class:`SKLearnModel`:
Set `input_chunk_length`, `output_chunk_length`, and `lags_covariates`.
`input_chunk_length` is the absolute value of the minimum target lag `abs(min(lags))` used with the
`SKLearnModel`.
Set `output_chunk_length`, and `lags_covariates` with the identical values used at forecasting model
creation. For the covariates lags, use `lags_past_covariates` for class:`PastCovariatesIndexGenerator`,
and `lags_future_covariates` for class:`PastCovariatesIndexGenerator`.
- in combination with :class:`TorchForecastingModel`:
Set `input_chunk_length`, and `output_chunk_length` with the identical values used at forecasting model
creation.

Parameters
----------
Expand Down
8 changes: 4 additions & 4 deletions darts/dataprocessing/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@ def inverse_transform(
) -> Union[TimeSeries, Sequence[TimeSeries]]:
"""
For each data transformer in the pipeline, inverse-transform data. Then inverse transformed data is passed to
the next transformer. Transformers are traversed in reverse order. Raises value error if not all of the
transformers are invertible and ``partial`` is set to `False`. Set ``partial`` to True for inverting only the
InvertibleDataTransformer in the pipeline.
the next transformer. Transformers are traversed in reverse order. Raises value error if not all transformers
are invertible and `partial` is set to `False`. Set `partial` to True for inverting only the
`InvertibleDataTransformer` in the pipeline.

Parameters
----------
data
(Sequence of) TimeSeries to be inverse transformed.
partial
If set to `True`, the inverse transformation is applied even if the pipeline is not fully invertible,
calling `inverse_transform()` only on the `InvertibleDataTransformer`s
calling `inverse_transform()` only on transformers of type `InvertibleDataTransformer`.
series_idx
Optionally, the index(es) of each series corresponding to their positions within the series used to fit
the transformer (to retrieve the appropriate transformer parameters).
Expand Down
Loading