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

lint: default pre-commit hooks & fixing #2324

Merged
merged 8 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage:
status:
project: off
patch: off
patch: off
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Checklist before merging this PR:
- [ ] Mentioned all issues that this PR fixes or addresses.
- [ ] Summarized the updates of this PR under **Summary**.
- [ ] Added an entry under **Unreleased** in the [Changelog](../CHANGELOG.md).
- [ ] Added an entry under **Unreleased** in the [Changelog](../CHANGELOG.md).

<!-- Please mention an issue this pull request addresses. -->
Fixes #.
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
autoupdate_schedule: quarterly
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: check-yaml
exclude: "conda_recipe/darts/meta.yaml"
- id: check-toml
- id: detect-private-key

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
Expand Down
40 changes: 20 additions & 20 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ To ensure you don't need to worry about formatting and linting when contributing
Please follow the procedure described in [INSTALL.md](https://github.com/unit8co/darts/blob/master/INSTALL.md#test-environment-appple-m1-processor)
to set up a x_64 emulated environment. For the development environment, instead of installing Darts with
`pip install darts`, instead go to the darts cloned repo location and install the packages with: `pip install -r requirements/dev-all.txt`.
If necessary, follow the same steps to setup libomp for lightgbm.
If necessary, follow the same steps to setup libomp for lightgbm.
Finally, verify your overall environment setup by successfully running all unitTests with gradlew or pytest.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ RUN pip install -e .

# assuming you are working from inside your darts directory:
# docker build . -t darts-test:latest
# docker run -it -v $(pwd)/:/app/ darts-test:latest bash
# docker run -it -v $(pwd)/:/app/ darts-test:latest bash
8 changes: 4 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Below, we detail how to install Darts using either `conda` or `pip`.
## From PyPI
Install Darts with all models except the ones from optional dependencies (Prophet, LightGBM, CatBoost, see more on that [here](#enabling-optional-dependencies)): `pip install darts`.

If this fails on your platform, please follow the official installation
If this fails on your platform, please follow the official installation
guide for [PyTorch](https://pytorch.org/get-started/locally/), then try installing Darts again.

As some dependencies are relatively big or involve non-Python dependencies,
Expand Down Expand Up @@ -37,8 +37,8 @@ As some models have relatively heavy dependencies, we provide four conda-forge p
## Other Information

### Enabling Optional Dependencies
As of version 0.25.0, the default `darts` package does not install Prophet, CatBoost, and LightGBM dependencies anymore, because their
build processes were too often causing issues. We continue supporting the model wrappers `Prophet`, `CatBoostModel`, and `LightGBMModel` in Darts though. If you want to use any of them, you will need to manually install the corresponding packages (or install a Darts flavor as described above).
As of version 0.25.0, the default `darts` package does not install Prophet, CatBoost, and LightGBM dependencies anymore, because their
build processes were too often causing issues. We continue supporting the model wrappers `Prophet`, `CatBoostModel`, and `LightGBMModel` in Darts though. If you want to use any of them, you will need to manually install the corresponding packages (or install a Darts flavor as described above).

#### Prophet
Install the `prophet` package (version 1.1.1 or more recent) using the [Prophet install guide](https://facebook.github.io/prophet/docs/installation.html#python)
Expand Down Expand Up @@ -99,4 +99,4 @@ To build documentation locally just run
```bash
./gradlew buildDocs
```
After that docs will be available in `./docs/build/html` directory. You can just open `./docs/build/html/index.html` using your favourite browser.
After that docs will be available in `./docs/build/html` directory. You can just open `./docs/build/html/index.html` using your favourite browser.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ on time series. It contains a variety of models, from classics such as ARIMA to
deep neural networks. The forecasting models can all be used in the same way,
using `fit()` and `predict()` functions, similar to scikit-learn.
The library also makes it easy to backtest models,
combine the predictions of several models, and take external data into account.
Darts supports both univariate and multivariate time series and models.
combine the predictions of several models, and take external data into account.
Darts supports both univariate and multivariate time series and models.
The ML-based models can be trained on potentially large datasets containing multiple time
series, and some of the models offer a rich support for probabilistic forecasting.

Expand Down Expand Up @@ -59,7 +59,7 @@ Once your environment is set up you can install darts using pip:

pip install darts

For more details you can refer to our
For more details you can refer to our
[installation instructions](https://github.com/unit8co/darts/blob/master/INSTALL.md).

## Example Usage
Expand Down Expand Up @@ -166,15 +166,15 @@ series.plot()
* **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.

* **Multiple series training (global models):** All machine learning based models (incl. all neural networks)
* **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.

* **Probabilistic Support:** `TimeSeries` objects can (optionally) represent stochastic
time series; this can for instance be used to get confidence intervals, and many models support different
flavours of probabilistic forecasting (such as estimating parametric distributions or quantiles).
Some anomaly detection scorers are also able to exploit these predictive distributions.

* **Past and Future Covariates support:** Many models in Darts support past-observed and/or future-known
* **Past and Future Covariates support:** Many models in Darts support past-observed and/or future-known
covariate (external data) time series as inputs for producing forecasts.

* **Static Covariates support:** In addition to time-dependent data, `TimeSeries` can also contain
Expand Down Expand Up @@ -262,7 +262,7 @@ on bringing more models and features.


## Community & Contact
Anyone is welcome to join our [Gitter room](https://gitter.im/u8darts/darts) to ask questions, make proposals,
Anyone is welcome to join our [Gitter room](https://gitter.im/u8darts/darts) to ask questions, make proposals,
discuss use-cases, and more. If you spot a bug or have suggestions, GitHub issues are also welcome.

If what you want to tell us is not suitable for Gitter or Github,
Expand Down
4 changes: 2 additions & 2 deletions darts/ad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
or for series accompanied by some predictions (``score_from_prediction()``).
Scorers can be trainable (e.g., ``KMeansScorer``) or not (e.g., ``NormScorer``).

* `Anomaly Models <https://unit8co.github.io/darts/generated_api/darts.ad.anomaly_model.html>`_
* `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 (``ForecastingAnomalyModel``) or filtering models (``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>`_:
* `Anomaly Detectors <https://unit8co.github.io/darts/generated_api/darts.ad.detectors.html>`_:
transform raw time series (such as anaomly scores) into binary anomaly time series.

* `Anomaly Aggregators <https://unit8co.github.io/darts/generated_api/darts.ad.aggregators.html>`_:
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 @@ -30,7 +30,7 @@
between the 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>`_
can be used to conveniently combine any of Darts forecasting and filtering models with one or multiple scorers.

Expand Down
2 changes: 1 addition & 1 deletion datasets/heart_rate.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1798,4 +1798,4 @@ Heart rate
101.623
99.5679
99.1835
98.8567
98.8567
2 changes: 1 addition & 1 deletion datasets/ice_cream_heater.csv
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ Month,heater,ice cream
2020-03,25,44
2020-04,25,53
2020-05,27,70
2020-06,24,74
2020-06,24,74
1 change: 0 additions & 1 deletion datasets/monthly-milk-incomplete.csv
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,3 @@
"1975-08",858
"1975-11",797
"1975-12",843

1 change: 0 additions & 1 deletion datasets/monthly-milk.csv
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,3 @@
"1975-10",827
"1975-11",797
"1975-12",843

2 changes: 1 addition & 1 deletion datasets/monthly-sunspots.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2818,4 +2818,4 @@
"1983-09",50.3
"1983-10",55.8
"1983-11",33.3
"1983-12",33.4
"1983-12",33.4
2 changes: 1 addition & 1 deletion datasets/temps.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3648,4 +3648,4 @@ Date,Daily minimum temperatures
12/28/1990,13.6
12/29/1990,13.5
12/30/1990,15.7
12/31/1990,13
12/31/1990,13
2 changes: 1 addition & 1 deletion datasets/us_gasoline.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1576,4 +1576,4 @@ Week,Gasoline
03/1/1991,7224
02/22/1991,6582
02/15/1991,6433
02/8/1991,6621
02/8/1991,6621
2 changes: 1 addition & 1 deletion docs/source/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You will find here some more detailed information about Darts.
.. userguide/probabilistic_forecasting.md

.. userguide/ensembling.md

.. userguide/filtering_models.md

.. userguide/preprocessing_and_pipelines.md
Expand Down
8 changes: 4 additions & 4 deletions docs/userguide/covariates.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ Let's have a look at some examples of past, future, and static covariates:
- daily average **forecasted** temperatures (known in the future)
- day of week, month, year, ...
- `static_covariates`: time independent/constant/static `target` characteristics
- categorical:
- categorical:
- location of `target` (country, city, .. name)
- `target` identifier: (product ID, store ID, ...)
- numerical:
- population of `target`'s country/market area (assuming it stays constant over the forecasting horizon)
- average temperature of `target`'s region (assuming it stays constant over the forecasting horizon)


Temporal attributes are powerful because they are known in advance and can help models capture trends and / or seasonal patterns of the `target` series.
Static attributes are powerful when working with multiple `targets` (either multiple `TimeSeries`, or multivariate series containing multiple dimensions each). The time independent information can help models identify the nature/environment of the underlying series and improve forecasts across different `targets`.
Expand Down Expand Up @@ -148,8 +148,8 @@ GFMs are models that can be trained on multiple target (and covariate) time seri
| [NHiTSModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.nhits.html#darts.models.forecasting.nhits.NHiTSModel) | ✅ | | |
| [TCNModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tcn_model.html#darts.models.forecasting.tcn_model.TCNModel) | ✅ | | |
| [TransformerModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.transformer_model.html#darts.models.forecasting.transformer_model.TransformerModel) | ✅ | | |
| [TFTModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tft_model.html#darts.models.forecasting.tft_model.TFTModel) | ✅ | ✅ | ✅ |
| [DLinearModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.dlinear.html#darts.models.forecasting.dlinear.DLinearModel) | ✅ | ✅ | ✅ |
| [TFTModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tft_model.html#darts.models.forecasting.tft_model.TFTModel) | ✅ | ✅ | ✅ |
| [DLinearModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.dlinear.html#darts.models.forecasting.dlinear.DLinearModel) | ✅ | ✅ | ✅ |
| [NLinearModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.nlinear.html#darts.models.forecasting.nlinear.NLinearModel) | ✅ | ✅ | ✅ |
| [TiDEModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tide_model.html#darts.models.forecasting.tide_model.TiDEModel) | ✅ | ✅ | ✅ |
| [TSMixerModel](https://unit8co.github.io/darts/generated_api/darts.models.forecasting.tsmixer_model.html#darts.models.forecasting.tsmixer_model.TSMixerModel) | ✅ | ✅ | ✅ |
Expand Down
20 changes: 10 additions & 10 deletions docs/userguide/forecasting_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ by calling the `fit()` function, and finally they are used to obtain one or seve
from darts.models import NaiveSeasonal

naive_model = NaiveSeasonal(K=1) # init
naive_model.fit(train) # fit
naive_model.fit(train) # fit
naive_forecast = naive_model.predict(n=36) # predict
```

Expand Down Expand Up @@ -111,7 +111,7 @@ These models are shown with a "✅" under the `Multivariate` column on the [mode
## Handling multiple series

Some models support being fit on multiple time series. To do this, it is enough to simply provide a Python `Sequence` of `TimeSeries` (for instance a list of `TimeSeries`) to `fit()`. When a model is fit this way, the `predict()` function will expect the argument `series` to be set, containing
one or several `TimeSeries` (i.e., a single or a `Sequence` of `TimeSeries`) that need to be forecasted.
one or several `TimeSeries` (i.e., a single or a `Sequence` of `TimeSeries`) that need to be forecasted.
The advantage of training on multiple series is that a single model can be exposed to more patterns occurring across all series in the training dataset. That can often be beneficial, especially for larger models with more capacity.

In turn, the advantage of having `predict()` providing forecasts for potentially several series at once is that the computation can often be batched and vectorized across the multiple series, which is computationally faster than calling `predict()` multiple times on isolated series.
Expand Down Expand Up @@ -178,9 +178,9 @@ pred.plot(label='forecast')
![Exponential Smoothing](./images/probabilistic/example_ets.png)

### Probabilistic neural networks
All neural networks (torch-based models) in Darts have a rich support to estimate different kinds of probability distributions.
When creating the model, it is possible to provide one of the *likelihood models* available in [darts.utils.likelihood_models](https://unit8co.github.io/darts/generated_api/darts.utils.likelihood_models.html), which determine the distribution that will be estimated by the model.
In such cases, the model will output the parameters of the distribution, and it will be trained by minimising the negative log-likelihood of the training samples.
All neural networks (torch-based models) in Darts have a rich support to estimate different kinds of probability distributions.
When creating the model, it is possible to provide one of the *likelihood models* available in [darts.utils.likelihood_models](https://unit8co.github.io/darts/generated_api/darts.utils.likelihood_models.html), which determine the distribution that will be estimated by the model.
In such cases, the model will output the parameters of the distribution, and it will be trained by minimising the negative log-likelihood of the training samples.
Most of the likelihood models also support prior values for the distribution's parameters, in which case the training loss is regularized by a Kullback-Leibler divergence term pushing the resulting distribution in the direction of the distribution specified by the prior parameters.
The strength of this regularization term can also be specified when creating the likelihood model object.

Expand All @@ -201,7 +201,7 @@ train = scaler.fit_transform(train)
val = scaler.transform(val)
series = scaler.transform(series)

model = TCNModel(input_chunk_length=30,
model = TCNModel(input_chunk_length=30,
output_chunk_length=12,
likelihood=LaplaceLikelihood(prior_b=0.1))
model.fit(train, epochs=400)
Expand Down Expand Up @@ -232,7 +232,7 @@ train = scaler.fit_transform(train)
val = scaler.transform(val)
series = scaler.transform(series)

model = TCNModel(input_chunk_length=30,
model = TCNModel(input_chunk_length=30,
output_chunk_length=12,
likelihood=QuantileRegression(quantiles=[0.01, 0.05, 0.2, 0.5, 0.8, 0.95, 0.99]))
model.fit(train, epochs=400)
Expand Down Expand Up @@ -291,8 +291,8 @@ from darts.models import LinearRegressionModel
series = AirPassengersDataset().load()
train, val = series[:-36], series[-36:]

model = LinearRegressionModel(lags=30,
likelihood="quantile",
model = LinearRegressionModel(lags=30,
likelihood="quantile",
quantiles=[0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95])
model.fit(train)
pred = model.predict(n=36, num_samples=500)
Expand All @@ -304,4 +304,4 @@ pred.plot(label='forecast')
![quantile linear regression](./images/probabilistic/example_linreg_quantile.png)


[1] Yarin Gal, Zoubin Ghahramani, ["Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning"](https://arxiv.org/abs/1506.02142)
[1] Yarin Gal, Zoubin Ghahramani, ["Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning"](https://arxiv.org/abs/1506.02142)
Loading
Loading