Skip to content

changes in Test Val Mask #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions notebooks/Chapter04/01-Setting up Experiment Harness.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,13 @@
}
],
"source": [
"test_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==2)\n",
"val_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==1)\n",
"# test_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==2)\n",
"# val_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==1)\n",
"\n",
"\"\"\"To get the last year and last months values from the dataset without specifying manually.\"\"\"\n",
"\n",
"test_mask = (exp_block_df.timestamp.dt.year==exp_block_df.timestamp.dt.to_period('M').unique()[-1].year) & (exp_block_df.timestamp.dt.month==exp_block_df.timestamp.dt.to_period('M').unique()[-1].month)\n",
"val_mask = (exp_block_df.timestamp.dt.year==exp_block_df.timestamp.dt.to_period('M').unique()[-1].year) & (exp_block_df.timestamp.dt.month==exp_block_df.timestamp.dt.to_period('M').unique()[-2].month)\n",
"\n",
"train = exp_block_df[~(val_mask|test_mask)]\n",
"val = exp_block_df[val_mask]\n",
Expand Down Expand Up @@ -1188,8 +1193,11 @@
}
],
"source": [
"test_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==2)\n",
"val_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==1)\n",
"# test_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==2)\n",
"# val_mask = (exp_block_df.timestamp.dt.year==2014) & (exp_block_df.timestamp.dt.month==1)\n",
"\n",
"test_mask = (exp_block_df.timestamp.dt.year==exp_block_df.timestamp.dt.to_period('M').unique()[-1].year) & (exp_block_df.timestamp.dt.month==exp_block_df.timestamp.dt.to_period('M').unique()[-1].month)\n",
"val_mask = (exp_block_df.timestamp.dt.year==exp_block_df.timestamp.dt.to_period('M').unique()[-1].year) & (exp_block_df.timestamp.dt.month==exp_block_df.timestamp.dt.to_period('M').unique()[-2].month)\n",
"\n",
"train = exp_block_df[~(val_mask|test_mask)]\n",
"val = exp_block_df[val_mask]\n",
Expand Down Expand Up @@ -1227,7 +1235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down