Skip to content

Commit

Permalink
Merge branch 'master' into support/wrapped-models-in-gridsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
madtoinou committed Jun 20, 2024
2 parents 2122b09 + 3115bb6 commit 1ec6e12
Show file tree
Hide file tree
Showing 12 changed files with 3,976 additions and 652 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)|dev
current_version = 0.29.0
current_version = 0.30.0

[bumpversion:file:setup.py]

Expand Down
61 changes: 37 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@ but cannot always guarantee backwards compatibility. Changes that may **break co

## [Unreleased](https://github.com/unit8co/darts/tree/master)

[Full Changelog](https://github.com/unit8co/darts/compare/0.29.0...master)
[Full Changelog](https://github.com/unit8co/darts/compare/0.30.0...master)

### For users of the library:
**Improved**
- 🚀🚀 Improvements to `GlobalForecastingModel` (regression-, ensemble-, and neural network models) : [#2404](https://github.com/unit8co/darts/pull/2404), [#2410](https://github.com/unit8co/darts/pull/2410) and [#2417](https://github.com/unit8co/darts/pull/2417) by [Anton Ragot](https://github.com/AntonRagot) and [Dennis Bader](https://github.com/dennisbader).
- Added parameters `sample_weight` and `val_sample_weight` to `fit()`, `historical_forecasts()`, `backtest()`, `residuals`, and `gridsearch()` to apply weights to each observation, label (each step in the output chunk), and target component in the training and evaluation set. Supported by both deterministic and probabilistic models. The sample weight can either be `TimeSeries` themselves or built-in weight generators "linear" and "exponential" decay. In case of a `TimeSeries` it is handled identically as the covariates (e.g. pass multiple weight series with multiple target series, relevant time frame extraction is handled automatically for you, ...).
- Improvements to the Anomaly Detection Module through major refactor. The refactor includes major performance optimization for the majority of the processes and improvements to the API, consistency, reliability, and the documentation. Some of these necessary changes come at the cost of breaking changes : [#1477](https://github.com/unit8co/darts/pull/1477) by [Dennis Bader](https://github.com/dennisbader), [Samuele Giuliano Piazzetta](https://github.com/piaz97), [Antoine Madrona](https://github.com/madtoinou), [Julien Herzen](https://github.com/hrzn), [Julien Adda](https://github.com/julien12234).
- 🚀🚀 Added an example notebook that showcases how to use Darts for Time Series Anomaly Detection
- Added a new dataset for anomaly detection with the number of taxi passengers in New York from the year 2014 to 2015.
- `FittableWindowScorer` (KMeans, PyOD, and Wasserstein Scorers) now accept any of darts "per-time" step metrics as difference function `diff_fn`.
- `ForecastingAnomalyModel` is now much faster thanks to optimized historical forecasts to generate the prediction input for the scorers. We also added more control over the historical forecasts generation through additional parameters in all model methods.

**Fixed**

**Dependencies**

### For developers of the library:

## [0.30.0](https://github.com/unit8co/darts/tree/0.30.0) (2024-06-19)
### For users of the library:
**Improved**
- 🚀🚀 All `GlobalForecastingModel` now support being trained with sample weights (regression-, ensemble-, and neural network models) : [#2404](https://github.com/unit8co/darts/pull/2404), [#2410](https://github.com/unit8co/darts/pull/2410), [#2417](https://github.com/unit8co/darts/pull/2417) and [#2418](https://github.com/unit8co/darts/pull/2418) by [Anton Ragot](https://github.com/AntonRagot) and [Dennis Bader](https://github.com/dennisbader).
- Added parameters `sample_weight` and `val_sample_weight` to `fit()`, `historical_forecasts()`, `backtest()`, `residuals`, and `gridsearch()` to apply weights to each observation, label (each step in the output chunk), and target component in the training and evaluation set. Supported by both deterministic and probabilistic models. The sample weight can either be `TimeSeries` themselves or built-in weight generators "linear" and "exponential" decay. In case of a `TimeSeries` it is handled identically as the covariates (e.g. pass multiple weight series with multiple target series, relevant time frame extraction is handled automatically for you, ...). You can find an example [here](https://unit8co.github.io/darts/quickstart/00-quickstart.html#Sample-Weights).
- 🚀🚀 Improvements to the Anomaly Detection Module through major refactor. The refactor includes major performance optimization for the majority of processes and improvements to the API, consistency, reliability, and the documentation. Some of these necessary changes come at the cost of breaking changes : [#1477](https://github.com/unit8co/darts/pull/1477) by [Dennis Bader](https://github.com/dennisbader), [Samuele Giuliano Piazzetta](https://github.com/piaz97), [Antoine Madrona](https://github.com/madtoinou), [Julien Herzen](https://github.com/hrzn), [Julien Adda](https://github.com/julien12234).
- Added an [example notebook](https://unit8co.github.io/darts/examples/22-anomaly-detection-examples.html) that showcases how to use Darts for Time Series Anomaly Detection.
- Added a new dataset `TaxiNewYorkDataset` for anomaly detection with the number of taxi passengers in New York from the years 2014 and 2015.
- `FittableWindowScorer` (KMeans, PyOD, and Wasserstein Scorers) now accept any of darts ["per-time" step metrics](https://unit8co.github.io/darts/generated_api/darts.metrics.html) as difference function `diff_fn`.
- `ForecastingAnomalyModel` is now much faster in generating forecasts (input for the scorers) thanks to optimized historical forecasts. We also added more control over the historical forecasts generation through additional parameters in all model methods.
- 🔴 Breaking changes:
- `FittableWindowScorer` (KMeans, PyOD, and Wasserstein Scorers) now expects `diff_fn` to be one of Darts "per-time" step metrics
- `ForecastingAnomalyModel` : `model` is now enforced to be a `GlobalForecastingModel`
- `*.eval_accuracy()`: (Aggregators, Detectors, Filtering/Forecasting Anomaly Models, Scorers)
- renamed method to `eval_metric()`:
- `*.eval_accuracy()` : (Aggregators, Detectors, Filtering/Forecasting Anomaly Models, Scorers)
- renamed method to `eval_metric()` :
- renamed params `actual_anomalies` to `anomalies`, and `anomaly_score` to `pred_scores`
- `*.show_anomalies()`: (Filtering/Forecasting Anomaly Models, Scorers)
- `*.show_anomalies()` : (Filtering/Forecasting Anomaly Models, Scorers)
- renamed params `actual_anomalies` to `anomalies`
- `*.fit()` (Filtering/Forecasting Anomaly Models)
- renamed params `actual_anomalies` to `anomalies`
Expand All @@ -35,33 +45,36 @@ but cannot always guarantee backwards compatibility. Changes that may **break co
- `darts.ad.utils.eval_accuracy_from_binary_prediction` :
- renamed function to `eval_metric_from_binary_prediction`
- renamed params `actual_anoamlies` to `anomalies`, and `binary_pred_anomalies` to `pred_anomalies`
- `darts.ad.utils.show_anomalies_from_scores`:
- `darts.ad.utils.show_anomalies_from_scores` :
- renamed params `series` to `actual_series`, `actual_anomalies` to `anomalies`, `model_output` to `pred_series`, and `anomaly_scores` to `pred_scores`
- Improvements to `TorchForecastingModel` : [#2295](https://github.com/unit8co/darts/pull/2295) by [Bohdan Bilonoh](https://github.com/BohdanBilonoh).
- Added `dataloader_kwargs` parameters to `fit*()`, `predict*()`, and `find_lr()` for more control over the PyTorch `DataLoader` setup.
- 🔴 Removed parameter `num_loader_workers` from `fit*()`, `predict*()`, `find_lr()`. You can now set the parameter through the `dataloader_kwargs` dict.
- Improvements to `DataTransformers` :
- Significant speed up when using `fit`, `fit_transform`, `transform`, and `inverse_transform` on a large number of series. The component masking logic was moved into the parallelized transform methods. [#2401](https://github.com/unit8co/darts/pull/2401) by [Dennis Bader](https://github.com/dennisbader).
- Improvements to `TimeSeries` : [#1477](https://github.com/unit8co/darts/pull/1477) by [Dennis Bader](https://github.com/dennisbader).
- New method `with_times_and_values()`, which returns a new series with a new time index and new values but with identical columns and metadata as the series called from (static covariates, hierarchy).
- New method `slice_intersect_times()`, which returns the sliced time index of a series, where the index has been intersected with another series.
- Method `with_values()` now also acts on array-like `values` rather than only on numpy arrays.
- Improvements to `TorchForecastingModel`: [#2295](https://github.com/unit8co/darts/pull/2295) by [Bohdan Bilonoh](https://github.com/BohdanBilonoh).
- Added `dataloader_kwargs` parameters to `fit*()`, `predict*()`, and `find_lr()` for more control over the PyTorch `DataLoader` setup.
- 🔴 Removed parameter `num_loader_workers` from `fit*()`, `predict*()`, `find_lr()`. You can now set the parameter through the `dataloader_kwargs` dict.
- Improvements to `DataTransformers`:
- Significant speed up when using `fit`, `fit_transform`, `transform`, and `inverse_transform` with a large number of series. The component masking logic was moved into the parallelized transform methods. [#2401](https://github.com/unit8co/darts/pull/2401) by [Dennis Bader](https://github.com/dennisbader).
- Improvements to quick start notebook : [#2418](https://github.com/unit8co/darts/pull/2418) by [Dennis Bader](https://github.com/dennisbader).
- Added examples for using sample weights, forecast start shifting, direct likelihood parameter predictions.
- Enhanced examples for historical forecasts, backtest and residuals.

**Fixed**
- Fixed a bug when using a `RegressionModel` (that supports validation series) with a validation set, and encoders and/or component-specific lags, where the encodings and component specific lags were not added to the set. [#2383](https://github.com/unit8co/darts/pull/2383) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug where `n_steps_between` did not work properly with custom business frequencies. This affected metrics computation. [#2357](https://github.com/unit8co/darts/pull/2357) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug when calling `predict()` with a `MixedCovariatesTorchModel` (e.g. TiDE, N/DLinear, ...) `n<output_chunk_length` and a list of series with length `len(series) < n`, where the predictions did not return the correct number of series. [#2374](https://github.com/unit8co/darts/pull/2374) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug when using a `RegressionModel` (that supports validation series) with a validation set: encoders, static covariates, and component-specific lags are now correctly applied to the validation set. [#2383](https://github.com/unit8co/darts/pull/2383) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug where `darts.utils.utils.n_steps_between()` did not work properly with custom business frequencies. This affected metrics computation. [#2357](https://github.com/unit8co/darts/pull/2357) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug when calling `predict()` with a `MixedCovariatesTorchModel` (e.g. TiDE, N/DLinear, ...), `n<output_chunk_length` and a list of series with length `len(series) < n`, where the predictions did not return the correct number of series. [#2374](https://github.com/unit8co/darts/pull/2374) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug when using a `TorchForecastingModel` with stateful torch metrics, where the metrics were incorrectly computed as non-stateful. [#2391](https://github.com/unit8co/darts/pull/2391) by [Tim Rosenflanz](https://github.com/tRosenflanz)

**Dependencies**
- We set an upper version cap on `numpy<2.0.0` until all dependencies have migrated. [#2413](https://github.com/unit8co/darts/pull/2413) by [Dennis Bader](https://github.com/dennisbader).

### For developers of the library:
**Dependencies**
- Improvements to linting via updated pre-commit configurations: [#2324](https://github.com/unit8co/darts/pull/2324) by [Jirka Borovec](https://github.com/borda).
- Improvements to unified linting by switch `isort` to Ruff's rule I. [#2339](https://github.com/unit8co/darts/pull/2339) by [Jirka Borovec](https://github.com/borda)
- Improvements to unified linting by switch `pyupgrade` to Ruff's rule UP. [#2340](https://github.com/unit8co/darts/pull/2340) by [Jirka Borovec](https://github.com/borda)
- Improvements to CI, running lint locally via pre-commit instead of particular tools. [#2327](https://github.com/unit8co/darts/pull/2327) by [Jirka Borovec](https://github.com/borda)
- We set an upper version cap on `numpy<2.0.0` until all dependencies have migrated. [#2413](https://github.com/unit8co/darts/pull/2413) by [Dennis Bader](https://github.com/dennisbader).


### For developers of the library:

## [0.29.0](https://github.com/unit8co/darts/tree/0.29.0) (2024-04-17)
### For users of the library:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ series.plot()
The `PyODScorer` makes it trivial to use PyOD detectors on time series.

* **Multivariate Support:** `TimeSeries` can be multivariate - i.e., contain multiple time-varying
dimensions instead of a single scalar value. Many models can consume and produce multivariate series.
dimensions/columns instead of a single scalar value. Many models can consume and produce multivariate series.

* **Multiple series training (global models):** All machine learning based models (incl. all neural networks)
support being trained on multiple (potentially multivariate) series. This can scale to large datasets too.
Expand All @@ -186,6 +186,13 @@ series.plot()
* **Regression Models:** It is possible to plug-in any scikit-learn compatible model
to obtain forecasts as functions of lagged values of the target series and covariates.

* **Training with sample weights:** All global models support being trained with sample weights. They can be
applied to each observation, forecasted time step and target column.

* **Forecast Start Shifting:** All global models support training and prediction on a shifted output window.
This is useful for example for Day-Ahead Market forecasts, or when the covariates (or target series) are reported
with a delay.

* **Explainability:** Darts has the ability to *explain* some forecasting models using Shap values.

* **Data processing:** Tools to easily apply (and revert) common transformations on
Expand Down
2 changes: 1 addition & 1 deletion conda_recipe/darts/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package:
name: "darts"
version: "0.29.0"
version: "0.30.0"

source:
# root folder, not the package
Expand Down
2 changes: 1 addition & 1 deletion darts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from darts.timeseries import TimeSeries, concatenate

__version__ = "0.29.0"
__version__ = "0.30.0"

colors = cycler(
color=["black", "003DFD", "b512b8", "11a9ba", "0d780f", "f77f07", "ba0f0f"]
Expand Down
9 changes: 3 additions & 6 deletions darts/tests/models/forecasting/test_backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
ARIMA,
FFT,
ExponentialSmoothing,
LinearRegressionModel,
NaiveDrift,
NaiveSeasonal,
RandomForest,
Theta,
)
from darts.tests.conftest import TORCH_AVAILABLE, tfm_kwargs
Expand All @@ -29,12 +31,7 @@


if TORCH_AVAILABLE:
from darts.models import (
BlockRNNModel,
LinearRegressionModel,
RandomForest,
TCNModel,
)
from darts.models import BlockRNNModel, TCNModel


def get_dummy_series(
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
project = "darts"
copyright = f"2020 - {datetime.now().year}, Unit8 SA (Apache 2.0 License)"
author = "Unit8 SA"
version = "0.29.0"
version = "0.30.0"


# -- General configuration ---------------------------------------------------
Expand Down
4,535 changes: 3,921 additions & 614 deletions examples/00-quickstart.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/20-RegressionModel-examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@
" self.weights = weights\n",
" self.norm_coef = sum(weights)\n",
"\n",
" def fit(self, X: np.ndarray, y: np.ndarray):\n",
" def fit(self, X: np.ndarray, y: np.ndarray, *args, **kwargs):\n",
" return self\n",
"\n",
" def predict(self, X: np.ndarray):\n",
Expand Down
Binary file modified examples/static/images/covariates-highlevel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def read_requirements(path):

setup(
name="darts",
version="0.29.0",
version="0.30.0",
description="A python library for easy manipulation and forecasting of time series.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion setup_u8darts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read_requirements(path):

setup(
name="u8darts",
version="0.29.0",
version="0.30.0",
description="A python library for easy manipulation and forecasting of time series.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 1ec6e12

Please sign in to comment.