Skip to content

Commit

Permalink
Fix to newer dates
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-braun committed Jul 15, 2020
1 parent 2f8f0fa commit 535de97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our `(AAPL, 2015-07-15 00:00:00)` is also in the data again:"
"Our `(AAPL, 2020-07-14 00:00:00)` is also in the data again:"
]
},
{
Expand All @@ -190,7 +190,7 @@
"metadata": {},
"outputs": [],
"source": [
"X.loc[\"AAPL\", pd.to_datetime('2015-07-15')]"
"X.loc[\"AAPL\", pd.to_datetime('2020-07-14')]"
]
},
{
Expand Down Expand Up @@ -242,7 +242,7 @@
"metadata": {},
"outputs": [],
"source": [
"y[\"AAPL\", pd.to_datetime(\"2015-07-15\")], df.loc[pd.to_datetime(\"2015-07-16\"), \"AAPL\"]"
"y[\"AAPL\", pd.to_datetime(\"2020-07-13\")], df.loc[pd.to_datetime(\"2020-07-14\"), \"AAPL\"]"
]
},
{
Expand Down Expand Up @@ -354,7 +354,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
27 changes: 10 additions & 17 deletions notebooks/examples/05 Timeseries Forecasting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"metadata": {},
"source": [
"The resulting dataframe now consists of these \"windows\" stamped out of the original dataframe.\n",
"For example all data with the `id = (AAPL, 2015-07-15 00:00:00)` comes from the original data of stock `AAPL` including the last 20 days until `2015-07-15`:"
"For example all data with the `id = (AAPL, 2020-07-14 00:00:00)` comes from the original data of stock `AAPL` including the last 20 days until `2020-07-14`:"
]
},
{
Expand All @@ -168,7 +168,7 @@
"metadata": {},
"outputs": [],
"source": [
"df_rolled[df_rolled[\"id\"] == (\"AAPL\", pd.to_datetime(\"2015-07-15\"))]"
"df_rolled[df_rolled[\"id\"] == (\"AAPL\", pd.to_datetime(\"2020-07-14\"))]"
]
},
{
Expand All @@ -177,8 +177,8 @@
"metadata": {},
"outputs": [],
"source": [
"df_melted[(df_melted[\"date\"] <= pd.to_datetime(\"2015-07-15\")) & \n",
" (df_melted[\"date\"] >= pd.to_datetime(\"2015-06-16\")) & \n",
"df_melted[(df_melted[\"date\"] <= pd.to_datetime(\"2020-07-14\")) & \n",
" (df_melted[\"date\"] >= pd.to_datetime(\"2020-06-15\")) & \n",
" (df_melted[\"Symbols\"] == \"AAPL\")]"
]
},
Expand Down Expand Up @@ -260,7 +260,7 @@
"The rolled (windowed) data sample is now in the correct format to use it for `tsfresh`s feature extraction.\n",
"As normal, features will be extracted using all data for a given `id`, which is in our case all data of a given window and a given id (one colored box in the graph above).\n",
"\n",
"If the feature extraction will return a row with the index `(AAPL, 2015-07-15 00:00:00)`, you now it has been calculated using the `AAPL` data up and including `2015-07-15` (and 20 days of history)."
"If the feature extraction will return a row with the index `(AAPL, 2020-07-14 00:00:00)`, you now it has been calculated using the `AAPL` data up and including `2020-07-14` (and 20 days of history)."
]
},
{
Expand Down Expand Up @@ -307,7 +307,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our `(AAPL, 2015-07-15 00:00:00)` is also in the data again:"
"Our `(AAPL, 2020-07-14 00:00:00)` is also in the data again:"
]
},
{
Expand All @@ -316,7 +316,7 @@
"metadata": {},
"outputs": [],
"source": [
"X.loc['2015-07-15']"
"X.loc['2020-07-14']"
]
},
{
Expand All @@ -339,7 +339,7 @@
"source": [
"We can now use the extracted features to train a regressor.\n",
"But what will be our targets?\n",
"The target for the row `2015-07-15` is the value on the next timestep (that would be `2015-07-16` in this case).\n",
"The target for the row `2020-07-13` is the value on the next timestep (that would be `2020-07-14` in this case).\n",
"\n",
"So all we need to do is go back to our original dataframe and take the stock value of tomorrow.\n",
"This is done with `shift`:"
Expand Down Expand Up @@ -367,14 +367,7 @@
"metadata": {},
"outputs": [],
"source": [
"y[\"2015-07-15\"], df[\"2015-07-16\"].iloc[0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The target for `2015-07-15` is to forecast the value of the next day, `2015-07-16`."
"y[\"2020-07-13\"], df[\"2020-07-14\"].iloc[0]"
]
},
{
Expand Down Expand Up @@ -514,7 +507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 535de97

Please sign in to comment.