-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #536 from JoaquinAmatRodrigo/0.10.x
0.10.x
- Loading branch information
Showing
86 changed files
with
17,498 additions
and
1,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.