-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
2,776 additions
and
3,846 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
670 changes: 670 additions & 0 deletions
670
notebooks/docs/0_core/0.1-time-series-custom-class.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
174 changes: 87 additions & 87 deletions
174
notebooks/docs/0.3-processing.ipynb → notebooks/docs/0_core/0.3-processing.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
110 changes: 58 additions & 52 deletions
110
notebooks/docs/0.4-modelling-libraries.ipynb → notebooks/docs/0_core/0.4-modelling.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,251 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "41296cc6-9d84-47c5-8a92-2d292f6f3c4a", | ||
"metadata": {}, | ||
"source": [ | ||
"# Module - Preprocessing" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "9286e0b8-3c78-4b0f-943c-d219e9840dfe", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import to be able to import python package from src\n", | ||
"import sys\n", | ||
"sys.path.insert(0, '../src')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "2028eed7-b1c3-4c9e-b6a0-00433caa7d0f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import numpy as np\n", | ||
"from darts.datasets import EnergyDataset" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "4733b4e6-71a2-42b2-93fd-a5615b84ac1a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ontime as on" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e24da8ab-6a83-4c2f-9ff0-c633d4693a91", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"## Load data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "e9a96d79-0423-4d79-b01d-726193216238", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ts = EnergyDataset().load()\n", | ||
"ts = ts.astype(np.float32)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1d4bec6b-eedb-4a88-ba68-dbeae5f0644e", | ||
"metadata": {}, | ||
"source": [ | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c2c873dd-8643-40cd-895b-fddd7a515c6d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Common Preprocessing" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "a630af5c-687e-48e2-a6d4-5a8cb1d1ec66", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ontime.module import preprocessing" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "9b508ee5-7c7e-4793-904e-45a40df354db", | ||
"metadata": {}, | ||
"source": [ | ||
"### Normalize" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"id": "a4b12f07-8a97-403a-a554-89e166574120", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/fred.montet/Library/Caches/pypoetry/virtualenvs/ontime-FpQu8-YN-py3.10/lib/python3.10/site-packages/sklearn/preprocessing/_data.py:479: RuntimeWarning: All-NaN slice encountered\n", | ||
" data_min = np.nanmin(X, axis=0)\n", | ||
"/Users/fred.montet/Library/Caches/pypoetry/virtualenvs/ontime-FpQu8-YN-py3.10/lib/python3.10/site-packages/sklearn/preprocessing/_data.py:480: RuntimeWarning: All-NaN slice encountered\n", | ||
" data_max = np.nanmax(X, axis=0)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"ts_t = preprocessing.common.normalize(ts)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "42428ed1-7556-4341-9675-bad6dca0ecac", | ||
"metadata": {}, | ||
"source": [ | ||
"### Train test split (for time series)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "8b67892d-db8c-4f12-93b6-147016da4186", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"train, test = preprocessing.common.train_test_split(ts_t, train_split=0.8)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "498b0e13-04bc-45ee-ab1a-3996fbfd1df2", | ||
"metadata": {}, | ||
"source": [ | ||
"### Split time series in chunks" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"id": "500e954a-82d6-4eff-bbdd-0b889c2a10f8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"train_list = preprocessing.common.split_by_length(train, 6)\n", | ||
"test_list = preprocessing.common.split_by_length(test, 6)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b4a88496-6b33-4bff-abb7-1d5ff4c81597", | ||
"metadata": {}, | ||
"source": [ | ||
"### Split in X and y" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"id": "f7897c44-71ba-4752-86c6-547387245ae4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"X_train, y_train = preprocessing.common.split_inputs_from_targets(train_list, 4, 2)\n", | ||
"X_test, y_test = preprocessing.common.split_inputs_from_targets(test_list, 4, 2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "9626370a-e4ba-4421-b40b-d6e7c5787beb", | ||
"metadata": {}, | ||
"source": [ | ||
"### Transform in generic data type " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"id": "a4ab9cfa-289d-4d8e-be40-d5d4247f5ab5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"X_train = preprocessing.common.timeseries_list_to_numpy(X_train)\n", | ||
"y_train = preprocessing.common.timeseries_list_to_numpy(y_train)\n", | ||
"X_test = preprocessing.common.timeseries_list_to_numpy(X_test)\n", | ||
"y_test = preprocessing.common.timeseries_list_to_numpy(y_test)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"id": "1b0a2843-6d02-4b08-96f8-91712e521bf5", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"(4675, 4, 28)\n", | ||
"(4675, 2, 28)\n", | ||
"(1168, 4, 28)\n", | ||
"(1168, 2, 28)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(X_train.shape)\n", | ||
"print(y_train.shape)\n", | ||
"print(X_test.shape)\n", | ||
"print(y_test.shape)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "54b0dfbd-be2f-4a3e-b152-f0bab31bb372", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.10.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.