-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Boilerplate for timeseries dataset
- Added a practice file Signed-off-by: Arkadip <[email protected]>
- Loading branch information
1 parent
65963e6
commit 4c75cf8
Showing
4 changed files
with
2,465 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"from preprocessing import Normalize_df" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div>\n", | ||
"<style scoped>\n", | ||
" .dataframe tbody tr th:only-of-type {\n", | ||
" vertical-align: middle;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe tbody tr th {\n", | ||
" vertical-align: top;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe thead th {\n", | ||
" text-align: right;\n", | ||
" }\n", | ||
"</style>\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
" <th></th>\n", | ||
" <th>time</th>\n", | ||
" <th>air_temperature_mean</th>\n", | ||
" <th>pressure</th>\n", | ||
" <th>wind_direction</th>\n", | ||
" <th>wind_speed</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <td>0</td>\n", | ||
" <td>0.000000</td>\n", | ||
" <td>0.370203</td>\n", | ||
" <td>0.103164</td>\n", | ||
" <td>0.732591</td>\n", | ||
" <td>0.625000</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>1</td>\n", | ||
" <td>0.000011</td>\n", | ||
" <td>0.322799</td>\n", | ||
" <td>0.268912</td>\n", | ||
" <td>0.838440</td>\n", | ||
" <td>0.354167</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>2</td>\n", | ||
" <td>0.000022</td>\n", | ||
" <td>0.302483</td>\n", | ||
" <td>0.709078</td>\n", | ||
" <td>0.988858</td>\n", | ||
" <td>0.260417</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>3</td>\n", | ||
" <td>0.000033</td>\n", | ||
" <td>0.246050</td>\n", | ||
" <td>0.850758</td>\n", | ||
" <td>0.239554</td>\n", | ||
" <td>0.093750</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>4</td>\n", | ||
" <td>0.000044</td>\n", | ||
" <td>0.194131</td>\n", | ||
" <td>0.827372</td>\n", | ||
" <td>0.345404</td>\n", | ||
" <td>0.291667</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" time air_temperature_mean pressure wind_direction wind_speed\n", | ||
"0 0.000000 0.370203 0.103164 0.732591 0.625000\n", | ||
"1 0.000011 0.322799 0.268912 0.838440 0.354167\n", | ||
"2 0.000022 0.302483 0.709078 0.988858 0.260417\n", | ||
"3 0.000033 0.246050 0.850758 0.239554 0.093750\n", | ||
"4 0.000044 0.194131 0.827372 0.345404 0.291667" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"dataset = Normalize_df(pd.read_csv('./dataset-daily.csv'))\n", | ||
"dataset.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"0 0.000000\n", | ||
"1 0.000011\n", | ||
"2 0.000022\n", | ||
"3 0.000033\n", | ||
"4 0.000044\n", | ||
" ... \n", | ||
"3648 0.999956\n", | ||
"3649 0.999967\n", | ||
"3650 0.999978\n", | ||
"3651 0.999989\n", | ||
"3652 1.000000\n", | ||
"Name: time, Length: 3653, dtype: float64" | ||
] | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"dataset.pop('time')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"z = np.zeros((6,4))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 21, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for i in range(6):\n", | ||
" z[i,:] = dataset.iloc[i].to_numpy()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"array([[0.37020316, 0.10316374, 0.73259053, 0.62500003],\n", | ||
" [0.3227991 , 0.26891239, 0.83844011, 0.35416667],\n", | ||
" [0.30248307, 0.70907824, 0.98885794, 0.26041667],\n", | ||
" [0.24604966, 0.85075755, 0.23955432, 0.09375 ],\n", | ||
" [0.19413093, 0.82737157, 0.3454039 , 0.29166667],\n", | ||
" [0.16704289, 0.66712609, 0.33983287, 0.23958333]])" | ||
] | ||
}, | ||
"execution_count": 22, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"z" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 23, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import torch" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 28, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"t = torch.from_numpy(z)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 30, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"tensor([[0.3702, 0.1032, 0.7326, 0.6250],\n", | ||
" [0.3228, 0.2689, 0.8384, 0.3542],\n", | ||
" [0.3025, 0.7091, 0.9889, 0.2604],\n", | ||
" [0.2460, 0.8508, 0.2396, 0.0938],\n", | ||
" [0.1941, 0.8274, 0.3454, 0.2917],\n", | ||
" [0.1670, 0.6671, 0.3398, 0.2396]])" | ||
] | ||
}, | ||
"execution_count": 30, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"t.type(torch.FloatTensor)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.7.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.