Skip to content

Commit

Permalink
Merge branch 'master' into feature/multivariate-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
madtoinou committed Sep 19, 2023
2 parents 450e081 + 2f7c9db commit 36d3f13
Show file tree
Hide file tree
Showing 62 changed files with 3,914 additions and 550 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.25.0
current_version = 0.26.0

[bumpversion:file:setup.py]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
example-name: [00-quickstart.ipynb, 01-multi-time-series-and-covariates.ipynb, 02-data-processing.ipynb, 03-FFT-examples.ipynb, 04-RNN-examples.ipynb, 05-TCN-examples.ipynb, 06-Transformer-examples.ipynb, 07-NBEATS-examples.ipynb, 08-DeepAR-examples.ipynb, 09-DeepTCN-examples.ipynb, 10-Kalman-filter-examples.ipynb, 11-GP-filter-examples.ipynb, 12-Dynamic-Time-Warping-example.ipynb, 13-TFT-examples.ipynb, 15-static-covariates.ipynb, 16-hierarchical-reconciliation.ipynb, 18-TiDE-examples.ipynb]
example-name: [00-quickstart.ipynb, 01-multi-time-series-and-covariates.ipynb, 02-data-processing.ipynb, 03-FFT-examples.ipynb, 04-RNN-examples.ipynb, 05-TCN-examples.ipynb, 06-Transformer-examples.ipynb, 07-NBEATS-examples.ipynb, 08-DeepAR-examples.ipynb, 09-DeepTCN-examples.ipynb, 10-Kalman-filter-examples.ipynb, 11-GP-filter-examples.ipynb, 12-Dynamic-Time-Warping-example.ipynb, 13-TFT-examples.ipynb, 15-static-covariates.ipynb, 16-hierarchical-reconciliation.ipynb, 18-TiDE-examples.ipynb, 19-EnsembleModel-examples.ipynb]
steps:
- name: "1. Clone repository"
uses: actions/checkout@v2
Expand Down
32 changes: 26 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,42 @@ 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.25.0...master)
[Full Changelog](https://github.com/unit8co/darts/compare/0.26.0...master)

### For users of the library:
### For developers of the library:

## [0.26.0](https://github.com/unit8co/darts/tree/0.26.0) (2023-09-16)
### For users of the library:

**Improved**
- `TimeSeries` with a `RangeIndex` starting in the negative start are now supported by `historical_forecasts`. [#1866](https://github.com/unit8co/darts/pull/1866) by [Antoine Madrona](https://github.com/madtoinou).
- Added a new argument `start_format` to `historical_forecasts()`, `backtest()` and `gridsearch` that allows to use an integer `start` either as the index position or index value/label for `series` indexed with a `pd.RangeIndex`. [#1866](https://github.com/unit8co/darts/pull/1866) by [Antoine Madrona](https://github.com/madtoinou).
- Added `RINorm` (Reversible Instance Norm) as an input normalization option for all `TorchForecastingModel` except `RNNModel`. Activate it with model creation parameter `use_reversible_instance_norm`. [#1969](https://github.com/unit8co/darts/pull/1969) by [Dennis Bader](https://github.com/dennisbader).
- Reduced the size of the Darts docker image `unit8/darts:latest`, and included all optional models as well as dev requirements. [#1878](https://github.com/unit8co/darts/pull/1878) by [Alex Colpitts](https://github.com/alexcolpitts96).
- Improvements to `RegressionModel`: [#1962](https://github.com/unit8co/darts/pull/1962) by [Antoine Madrona](https://github.com/madtoinou).
- 🚀🚀 All models now support component/column-specific lags for target, past, and future covariates series.
- Improvements to `TorchForecastingModel`:
- 🚀 Added `RINorm` (Reversible Instance Norm) as an input normalization option for all models except `RNNModel`. Activate it with model creation parameter `use_reversible_instance_norm`. [#1969](https://github.com/unit8co/darts/pull/1969) by [Dennis Bader](https://github.com/dennisbader).
- 🔴 Added past covariates feature projection to `TiDEModel` with parameter `temporal_width_past` following the advice of the model architect. Parameter `temporal_width` was renamed to `temporal_width_future`. Additionally, added the option to bypass the feature projection with `temporal_width_past/future=0`. [#1993](https://github.com/unit8co/darts/pull/1993) by [Dennis Bader](https://github.com/dennisbader).
- Improvements to `EnsembleModel`: [#1815](https://github.com/unit8co/darts/pull/#1815) by [Antoine Madrona](https://github.com/madtoinou) and [Dennis Bader](https://github.com/dennisbader).
- 🔴 Renamed model constructor argument `models` to `forecasting_models`.
- 🚀🚀 Added support for pre-trained `GlobalForecastingModel` as `forecasting_models` to avoid re-training when ensembling. This requires all models to be pre-trained global models.
- 🚀 Added support for generating the `forecasting_model` forecasts (used to train the ensemble model) with historical forecasts rather than direct (auto-regressive) predictions. Enable it with `train_using_historical_forecasts=True` at model creation.
- Added an example notebook for ensemble models.
- Improvements to historical forecasts, backtest and gridsearch: [#1866](https://github.com/unit8co/darts/pull/1866) by [Antoine Madrona](https://github.com/madtoinou).
- Added support for negative `start` values to start historical forecasts relative to the end of the target series.
- Added a new argument `start_format` that allows to use an integer `start` either as the index position or index value/label for `series` indexed with a `pd.RangeIndex`.
- Added support for `TimeSeries` with a `RangeIndex` starting at a negative integer.
- Other improvements:
- Reduced the size of the Darts docker image `unit8/darts:latest`, and included all optional models as well as dev requirements. [#1878](https://github.com/unit8co/darts/pull/1878) by [Alex Colpitts](https://github.com/alexcolpitts96).
- Added short examples in the docstring of all the models, including covariates usage and some model-specific parameters. [#1956](https://github.com/unit8co/darts/pull/1956) by [Antoine Madrona](https://github.com/madtoinou).
- Added method `TimeSeries.cumsum()` to get the cumulative sum of the time series along the time axis. [#1988](https://github.com/unit8co/darts/pull/1988) by [Eliot Zubkoff](https://github.com/Eliotdoesprogramming).

**Fixed**
- Fixed a bug in `TimeSeries.from_dataframe()` when using a pandas.DataFrame with `df.columns.name != None`. [#1938](https://github.com/unit8co/darts/pull/1938) by [Antoine Madrona](https://github.com/madtoinou).
- Fixed a bug in `RegressionEnsembleModel.extreme_lags` when the forecasting models have only covariates lags. [#1942](https://github.com/unit8co/darts/pull/1942) by [Antoine Madrona](https://github.com/madtoinou).
- Fixed a bug when using `TFTExplainer` with a `TFTModel` running on GPU. [#1949](https://github.com/unit8co/darts/pull/1949) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug in `TorchForecastingModel.load_weights()` that raised an error when loading the weights from a valid architecture. [#1952](https://github.com/unit8co/darts/pull/1952) by [Antoine Madrona](https://github.com/madtoinou).
- 🔴 Dropped support for lambda functions in `add_encoders`’s “custom” encoder in favor of named functions to ensure that models can be exported. [#1957](https://github.com/unit8co/darts/pull/1957) by [Antoine Madrona]
- Fixed a bug in `NLinearModel` where `normalize=True` and past covariates could not be used at the same time. [#1873](https://github.com/unit8co/darts/pull/1873) by [Eliot Zubkoff](https://github.com/Eliotdoesprogramming).
- Raise an error when an `EnsembleModel` containing at least one `LocalForecastingModel` is calling `historical_forecasts` with `retrain=False`. [#1815](https://github.com/unit8co/darts/pull/#1815) by [Antoine Madrona](https://github.com/madtoinou).
- 🔴 Dropped support for lambda functions in `add_encoders`’s “custom” encoder in favor of named functions to ensure that models can be exported. [#1957](https://github.com/unit8co/darts/pull/1957) by [Antoine Madrona](https://github.com/madtoinou).

### For developers of the library:

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.25.0"
version: "0.26.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 .timeseries import TimeSeries, concatenate

__version__ = "0.25.0"
__version__ = "0.26.0"

colors = cycler(
color=["black", "003DFD", "b512b8", "11a9ba", "0d780f", "f77f07", "ba0f0f"]
Expand Down
12 changes: 6 additions & 6 deletions darts/explainability/shap_explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ def _build_explainer_sklearn(

def _create_regression_model_shap_X(
self,
target_series,
past_covariates,
future_covariates,
target_series: Optional[Union[TimeSeries, Sequence[TimeSeries]]],
past_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]],
future_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]],
n_samples=None,
train=False,
) -> pd.DataFrame:
Expand All @@ -746,9 +746,9 @@ def _create_regression_model_shap_X(
"""

lags_list = self.model.lags.get("target")
lags_past_covariates_list = self.model.lags.get("past")
lags_future_covariates_list = self.model.lags.get("future")
lags_list = self.model._get_lags("target")
lags_past_covariates_list = self.model._get_lags("past")
lags_future_covariates_list = self.model._get_lags("future")

X, indexes = create_lagged_prediction_data(
target_series=target_series if lags_list else None,
Expand Down
8 changes: 3 additions & 5 deletions darts/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
from darts.models.forecasting.tft_model import TFTModel
from darts.models.forecasting.tide_model import TiDEModel
from darts.models.forecasting.transformer_model import TransformerModel


except ModuleNotFoundError:
logger.warning(
"Support for Torch based models not available. "
Expand All @@ -54,17 +52,17 @@
try:
from darts.models.forecasting.lgbm import LightGBMModel
except ModuleNotFoundError:
LightGBMModel = NotImportedModule(module_name="LightGBM")
LightGBMModel = NotImportedModule(module_name="LightGBM", warn=False)

try:
from darts.models.forecasting.prophet_model import Prophet
except ImportError:
Prophet = NotImportedModule(module_name="Prophet")
Prophet = NotImportedModule(module_name="Prophet", warn=False)

try:
from darts.models.forecasting.catboost_model import CatBoostModel
except ModuleNotFoundError:
CatBoostModel = NotImportedModule(module_name="CatBoost")
CatBoostModel = NotImportedModule(module_name="CatBoost", warn=False)

try:
from darts.models.forecasting.croston import Croston
Expand Down
25 changes: 24 additions & 1 deletion darts/models/forecasting/arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,37 @@ def __init__(
.. highlight:: python
.. code-block:: python
def encode_year(idx):
return (idx.year - 1950) / 50
add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Examples
--------
>>> from darts.datasets import AirPassengersDataset
>>> from darts.models import ARIMA
>>> from darts.utils.timeseries_generation import datetime_attribute_timeseries
>>> series = AirPassengersDataset().load()
>>> # optionally, use some future covariates; e.g. the value of the month encoded as a sine and cosine series
>>> future_cov = datetime_attribute_timeseries(series, "month", cyclic=True, add_length=6)
>>> # define ARIMA parameters
>>> model = ARIMA(p=12, d=1, q=2)
>>> model.fit(series, future_covariates=future_cov)
>>> pred = model.predict(6, future_covariates=future_cov)
>>> pred.values()
array([[451.36489334],
[416.88972829],
[443.10520391],
[481.07892911],
[502.11286509],
[555.50153984]])
"""
super().__init__(add_encoders=add_encoders)
self.order = p, d, q
Expand Down
25 changes: 24 additions & 1 deletion darts/models/forecasting/auto_arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,37 @@ def __init__(
.. highlight:: python
.. code-block:: python
def encode_year(idx):
return (idx.year - 1950) / 50
add_encoders={
'cyclic': {'future': ['month']},
'datetime_attribute': {'future': ['hour', 'dayofweek']},
'position': {'future': ['relative']},
'custom': {'future': [lambda idx: (idx.year - 1950) / 50]},
'custom': {'future': [encode_year]},
'transformer': Scaler()
}
..
Examples
--------
>>> from darts.datasets import AirPassengersDataset
>>> from darts.models import AutoARIMA
>>> from darts.utils.timeseries_generation import holidays_timeseries
>>> series = AirPassengersDataset().load()
>>> # optionally, use some future covariates; e.g. the value of the month encoded as a sine and cosine series
>>> future_cov = datetime_attribute_timeseries(series, "month", cyclic=True, add_length=6)
>>> # define some boundaries for the parameters
>>> model = AutoARIMA(start_p=8, max_p=12, start_q=1)
>>> model.fit(series, future_covariates=future_cov)
>>> pred = model.predict(6, future_covariates=future_cov)
>>> pred.values()
array([[449.79716178],
[416.31180633],
[445.28005229],
[485.27121314],
[507.61787454],
[561.26993332]])
"""
super().__init__(add_encoders=add_encoders)
self.model = PmdAutoARIMA(*autoarima_args, **autoarima_kwargs)
Expand Down
Loading

0 comments on commit 36d3f13

Please sign in to comment.