Skip to content

Commit

Permalink
Merge pull request #536 from JoaquinAmatRodrigo/0.10.x
Browse files Browse the repository at this point in the history
0.10.x
  • Loading branch information
JoaquinAmatRodrigo authored Sep 7, 2023
2 parents 37d6c10 + 79d3d9c commit 08c62ee
Show file tree
Hide file tree
Showing 86 changed files with 17,498 additions and 1,364 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ keywords:
- machine learning
- python
license: BSD 3-Clause License
version: 0.9.1
date-released: '2023-07'
version: 0.10.0
date-released: '2023-09'
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pip install skforecast
Specific version:

```bash
pip install skforecast==0.9.1
pip install skforecast==0.10.0
```

Latest (unstable):
Expand Down Expand Up @@ -93,14 +93,13 @@ pip install skforecast[plotting]
+ statsmodels>=0.12, <0.15
+ pmdarima>=2.0, <2.1

# What is new in skforecast 0.9.1?
# What is new in skforecast 0.10.0?

Visit the [release notes](https://github.com/JoaquinAmatRodrigo/skforecast/blob/master/changelog.md) to view all notable changes.

- [x] `ForecasterAutoregDirect` and `ForecasterAutoregMultiVariate` include the `n_jobs` argument in their `fit` method, allowing multi-process parallelization for improved performance.
- [x] All backtesting and grid search functions have been extended to include the `n_jobs` argument, allowing multi-process parallelization for improved performance.
- [x] Argument `refit` now can be also an `integer` in all backtesting dependent functions in modules `model_selection`, `model_selection_multiseries`, and `model_selection_sarimax`. This allows the Forecaster to be trained every this number of iterations.
- [x] `ForecasterAutoregMultiSeries` and `ForecasterAutoregMultiSeriesCustom` can be trained using series of different lengths. This means that the model can handle datasets with different numbers of data points in each series.
- [x] New `Sarimax.Sarimax` model. A wrapper of `statsmodels.SARIMAX` that follows the scikit-learn API and can be used with the `ForecasterSarimax`.
- [x] Added `skforecast.preprocessing.TimeSeriesDifferentiator` to preprocess time series by differentiating or integrating them (reverse differentiation).
- [x] Added `differentiation` argument to `ForecasterAutoreg` and `ForecasterAutoregCustom` to model the n-order differentiated time series using the new skforecast preprocessor `TimeSeriesDifferentiator`.
- [x] Bug fixes and performance improvements.


Expand All @@ -110,15 +109,15 @@ A **Forecaster** object in the skforecast library is a comprehensive container t

The **skforecast** library offers a variety of forecaster types, each tailored to specific requirements such as single or multiple time series, direct or recursive strategies, or custom predictors. Regardless of the specific forecaster type, all instances share the same API.

| Forecaster | Single series | Multiple series | Recursive strategy | Direct strategy | Probabilistic prediction | Exogenous features | Custom features |
|:-----------|:-------------:|:---------------:|:------------------:|:---------------:|:------------------------:|:------------------:|:---------------:|
|[ForecasterAutoreg](https://skforecast.org/latest/user_guides/autoregresive-forecaster.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:||
|[ForecasterAutoregCustom](https://skforecast.org/latest/user_guides/custom-predictors.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|
|[ForecasterAutoregDirect](https://skforecast.org/latest/user_guides/direct-multi-step-forecasting.html)|:heavy_check_mark:|||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:||
|[ForecasterMultiSeries](https://skforecast.org/latest/user_guides/independent-multi-time-series-forecasting.html)||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:||
|[ForecasterMultiSeriesCustom](https://skforecast.org/latest/user_guides/custom-predictors.html)||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|
|[ForecasterMultiVariate](https://skforecast.org/latest/user_guides/dependent-multi-series-multivariate-forecasting.html)||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:||
|[ForecasterSarimax](https://skforecast.org/latest/user_guides/forecasting-sarimax-arima.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:||
| Forecaster | Single series | Multiple series | Recursive strategy | Direct strategy | Probabilistic prediction | Time series differentiation | Exogenous features | Custom features |
|:-----------|:-------------:|:---------------:|:------------------:|:---------------:|:------------------------:|:---------------------------:|:------------------:|:---------------:|
|[ForecasterAutoreg](https://skforecast.org/latest/user_guides/autoregresive-forecaster.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:||
|[ForecasterAutoregCustom](https://skforecast.org/latest/user_guides/custom-predictors.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|
|[ForecasterAutoregDirect](https://skforecast.org/latest/user_guides/direct-multi-step-forecasting.html)|:heavy_check_mark:|||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:||
|[ForecasterMultiSeries](https://skforecast.org/latest/user_guides/independent-multi-time-series-forecasting.html)||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:||
|[ForecasterMultiSeriesCustom](https://skforecast.org/latest/user_guides/custom-predictors.html)||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|
|[ForecasterMultiVariate](https://skforecast.org/latest/user_guides/dependent-multi-series-multivariate-forecasting.html)||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:||:heavy_check_mark:||
|[ForecasterSarimax](https://skforecast.org/latest/user_guides/forecasting-sarimax-arima.html)|:heavy_check_mark:||:heavy_check_mark:||:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:||


# Main User Guides
Expand Down Expand Up @@ -208,17 +207,17 @@ If you use this software, please cite it using the following metadata.

**APA**:
```
Amat Rodrigo, J., & Escobar Ortiz, J. skforecast (Version 0.9.1) [Computer software]
Amat Rodrigo, J., & Escobar Ortiz, J. skforecast (Version 0.10.0) [Computer software]
```

**BibTeX**:
```
@software{skforecast,
author = {Amat Rodrigo, Joaquin and Escobar Ortiz, Javier},
license = {BSD 3-Clause License},
month = {7},
month = {9},
title = {{skforecast}},
version = {0.9.1},
version = {0.10.0},
year = {2023}
}
```
Expand Down
154 changes: 154 additions & 0 deletions dev/00_TimeSeriesDifferentiator.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
},
{
"data": {
"text/plain": [
"'/home/ubuntu/varios/skforecast'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"import sys\n",
"from pathlib import Path\n",
"sys.path.insert(1, str(Path.cwd().parent))\n",
"str(Path.cwd().parent)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from skforecast.preprocessing import TimeSeriesDifferentiator"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"y : [ 1. 4. 8. 10. 13. 22. 40. 46.]\n",
"diff 1: [nan 3. 4. 2. 3. 9. 18. 6.]\n",
"diff 2: [ nan nan 1. -2. 1. 6. 9. -12.]\n",
"diff 3: [ nan nan nan -3. 3. 5. 3. -21.]\n",
"last values y : [22. 40. 46.]\n",
"next window : [55. 70. 71.]\n",
"next window diff 1: [ 9. 15. 1.]\n",
"next window diff 2: [ 3. 6. -14.]\n",
"next window diff 3: [ 15. 3. -20.]\n"
]
}
],
"source": [
"series = np.array([ 1, 4, 8, 10, 13, 22, 40, 46, 55, 70 , 71], dtype=float)\n",
"y = series[:-3]\n",
"y_diff_1 = np.diff(y, n=1, prepend=np.nan)\n",
"y_diff_2 = np.diff(y_diff_1, n=1, prepend=np.nan)\n",
"y_diff_3 = np.diff(y_diff_2, n=1, prepend=np.nan)\n",
"last_values_y = y[-3:]\n",
"next_window = series[-3:]\n",
"next_window_diff_1 = np.diff(series, n=1)[-3:]\n",
"next_window_diff_2 = np.diff(series, n=2)[-3:]\n",
"next_window_diff_3 = np.diff(series, n=3)[-3:]\n",
"\n",
"print(\"y : \", y)\n",
"print(\"diff 1: \", y_diff_1)\n",
"print(\"diff 2: \", y_diff_2)\n",
"print(\"diff 3: \", y_diff_3)\n",
"print(\"last values y : \", last_values_y)\n",
"print(\"next window : \", next_window)\n",
"print(\"next window diff 1: \", next_window_diff_1)\n",
"print(\"next window diff 2: \", next_window_diff_2)\n",
"print(\"next window diff 3: \", next_window_diff_3)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"diferentiatior_1 = TimeSeriesDifferentiator(order=1)\n",
"diferentiatior_2 = TimeSeriesDifferentiator(order=2)\n",
"diferentiatior_3 = TimeSeriesDifferentiator(order=3)\n",
"\n",
"y_diff_1_hat = diferentiatior_1.fit_transform(y)\n",
"y_diff_2_hat = diferentiatior_2.fit_transform(y)\n",
"y_diff_3_hat = diferentiatior_3.fit_transform(y)\n",
"\n",
"y_inverse_1 = diferentiatior_1.inverse_transform(y_diff_1_hat)\n",
"y_inverse_2 = diferentiatior_2.inverse_transform(y_diff_2_hat)\n",
"y_inverse_3 = diferentiatior_3.inverse_transform(y_diff_3_hat)\n",
"\n",
"next_window_inverse_1 = diferentiatior_1.inverse_transform_next_window(next_window_diff_1)\n",
"next_window_inverse_2 = diferentiatior_2.inverse_transform_next_window(next_window_diff_2)\n",
"next_window_inverse_3 = diferentiatior_3.inverse_transform_next_window(next_window_diff_3) \n",
"\n",
"np.testing.assert_array_equal(y_diff_1_hat, y_diff_1)\n",
"np.testing.assert_array_equal(y_diff_2_hat, y_diff_2)\n",
"np.testing.assert_array_equal(y_diff_3_hat, y_diff_3)\n",
"\n",
"np.testing.assert_array_equal(y_inverse_1, y)\n",
"np.testing.assert_array_equal(y_inverse_2, y)\n",
"np.testing.assert_array_equal(y_inverse_3, y)\n",
"\n",
"np.testing.assert_array_equal(next_window_inverse_1, next_window)\n",
"np.testing.assert_array_equal(next_window_inverse_2, next_window)\n",
"np.testing.assert_array_equal(next_window_inverse_3, next_window)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "skforecast_py10",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "c78d62c1713fdacd99ef7c429003c7324b36fbb551fb8b6860a7ea73e9338235"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 08c62ee

Please sign in to comment.