Skip to content
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

Features/new nn functionality #21

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9477269
PatchTST with CI flag
aayugay99 Feb 3, 2025
f016fff
delete redundant code
aayugay99 Feb 3, 2025
aea1168
patchtst updated
aayugay99 Feb 5, 2025
60a78a6
CycleNet added
aayugay99 Feb 6, 2025
f9e2172
add inverse_transform parameter to predict
elineii Feb 6, 2025
4de5368
add non_norm parameter to rev_in
elineii Feb 6, 2025
e3aece6
add Embedding class (for value, pos, time embeds)
elineii Feb 6, 2025
6d53e0a
add slice_features functions
elineii Feb 6, 2025
f8fc814
add dlinear + gpt + time_mixer models
elineii Feb 6, 2025
e8ac9ad
fix slice_features functionality
elineii Feb 6, 2025
041523d
minor fix
aayugay99 Feb 6, 2025
2c9ea93
Merge branch 'features/new_nn_functionality' into features/patchtst
aayugay99 Feb 6, 2025
116ba53
fix docstrings
aayugay99 Feb 6, 2025
6312674
CycleNet_NN
aayugay99 Feb 6, 2025
d9b1268
remove revin for exog variables
aayugay99 Feb 6, 2025
3e68d8c
Merge pull request #22 from sb-ai-lab/features/patchtst
elineii Feb 6, 2025
2bc96f8
add TimesNet_NN
elineii Feb 6, 2025
37829c5
fix TimeMixer bug
aayugay99 Feb 7, 2025
ef3d386
fix PatchTST
aayugay99 Feb 7, 2025
ac9ec5c
reproducibility code and configs
aayugay99 Feb 10, 2025
5e4224f
pipeline fix
aayugay99 Feb 10, 2025
68ce503
GPT4TS and CycleNet fix
aayugay99 Feb 10, 2025
a4df9d1
add CycleGenerator to __init__.py
aayugay99 Feb 10, 2025
6ae9910
update configs
aayugay99 Feb 11, 2025
67976cf
update experiment pipeline
aayugay99 Feb 11, 2025
d3ca3c7
validation code
aayugay99 Feb 11, 2025
dbe0cba
make_step fix
aayugay99 Feb 11, 2025
6064274
update configs
aayugay99 Feb 11, 2025
9b5f4b3
small fix
aayugay99 Feb 11, 2025
d37cabf
Merge pull request #23 from sb-ai-lab/reproducibility
elineii Feb 14, 2025
aa71d44
add relative_steps_per_epoch and relative_steps parameters in schedul…
elineii Feb 14, 2025
34a8245
fix FlatWideMIMO features generating process and target reshapes (in …
elineii Feb 14, 2025
1854ecc
del log levels INFO2 and INFO3
elineii Feb 14, 2025
638f50a
fix transformers __init__ file
elineii Feb 14, 2025
4024855
add PyBoost
elineii Feb 14, 2025
e066988
add code and raw results of paper + new directory for results
elineii Feb 14, 2025
3ef79db
fix pipeline.output_features (they were in incorrect order with real …
elineii Feb 14, 2025
2fe9298
fix tests because of new changes in code
elineii Feb 14, 2025
e84bcd8
fix id_features_names in multivariate_columns_names
elineii Feb 14, 2025
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
3,670 changes: 672 additions & 2,998 deletions examples/Tutorial_4_Neural_Networks.ipynb

Large diffs are not rendered by default.

794 changes: 794 additions & 0 deletions examples/all_configurations_benchmark/alternative_aggregations.ipynb

Large diffs are not rendered by default.

193 changes: 193 additions & 0 deletions examples/all_configurations_benchmark/clean_results.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from copy import deepcopy\n",
"from datetime import datetime\n",
"from itertools import product\n",
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"from tqdm import tqdm"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"time_now = datetime.now().strftime(\"%Y-%m-%d\")\n",
"print(f\"Time: {time_now}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"MODELS = [\"PyBoost\", \"DLinear_NN\", \"PatchTST_NN\", \"GPT4TS_NN\", \"TimesNet_NN\", \"TimeMixer_NN\", \"CycleNet_NN\"]\n",
"DATASETS = [\"ILI\"]\n",
"STRATEGY_TIMES = [\n",
" \"FlatWideMIMOStrategy__model_horizon_NaN\",\n",
" \"MIMOStrategy__model_horizon_NaN\",\n",
" \"RecursiveStrategy__model_horizon_1.0\",\n",
" \"RecursiveStrategy__model_horizon_6.0\",\n",
"]\n",
"DATETIMES = [\"False\", \"with_normalization_over_all\"]\n",
"IDS = [\"False\", \"with_le_normalization_over_all\"]\n",
"TRANSFORMER_NAMES = [\n",
" \"NaN\",\n",
" \"DifferenceNormalizer\",\n",
" \"LastKnownNormalizer\",\n",
"]\n",
"TRANSFORMER_REGIMES = [\"NaN\", \"delta\"]\n",
"TRANSFORMER_TR_FEATURES = [\"True\"]\n",
"TRANSFORMER_TR_TARGETS = [\"True\"]\n",
"REGIMES = [\"multivariate\", \"global\"]\n",
"CI = [\"False\", \"True\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_path = f\"agg_results_{time_now}__normalized_True.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_df = pd.read_csv(df_path)\n",
"\n",
"# Convert bool to object\n",
"for col in raw_df.columns:\n",
" if raw_df[col].dtype == bool:\n",
" raw_df[col] = raw_df[col].astype(str)\n",
" print(f\"Converted {col} to object\")\n",
" \n",
"raw_df = raw_df.dropna(subset=['mae_test', 'rmse_test', 'fit_time_test',\n",
" 'forecast_time_test', 'mae_val', 'rmse_val', 'fit_time_val', 'forecast_time_val'])\n",
"# NaN to \"NaN\"\n",
"raw_df = raw_df.fillna(\"NaN\")\n",
"\n",
"raw_df = raw_df[raw_df[\"dateteime\"].isin(DATETIMES)]\n",
"raw_df = raw_df[raw_df[\"id\"].isin(IDS)]\n",
"\n",
"raw_df[\"tr_features\"] = raw_df[\"tr_features\"].str.replace(\"_metrics_test_v2.csv\", \"\", regex=False)\n",
"raw_df[\"tr_features\"] = raw_df[\"tr_features\"].str.replace(\"_metrics_test_v2_normalized.csv\", \"\", regex=False)\n",
"\n",
"# colname regime -> colname transormer_regime\n",
"# colname transformer -> colname transformer_name\n",
"# colname tr_target -> colname transformer_tr_target\n",
"# colname tr_features -> colname transformer_tr_features\n",
"raw_df = raw_df.rename(\n",
" columns={\n",
" \"dateteime\": \"datetime\",\n",
" \"regime\": \"transformer_regime\",\n",
" \"transformer\": \"transformer_name\",\n",
" \"tr_target\": \"transformer_tr_target\",\n",
" \"tr_features\": \"transformer_tr_features\",\n",
" }\n",
")\n",
"\n",
"# mult (\"False\" or \"True\") to regime (\"multivariate\" or \"global\")\n",
"raw_df[\"regime\"] = np.where(raw_df[\"mult\"] == \"False\", \"global\", \"multivariate\")\n",
"\n",
"# Concatenate strategy_time and model_horizon\n",
"raw_df[\"strategy_time\"] = (\n",
" raw_df[\"strategy_time\"] + \"__model_horizon_\" + raw_df[\"model_hor\"].astype(str)\n",
")\n",
"\n",
"# Drop unnecessary columns\n",
"raw_df = raw_df.drop(columns=[\"model_hor\", \"hor\", \"hist\", \"mult\"])\n",
"raw_df = raw_df.drop(columns=[\"dataset\", \"transformer_tr_target\", \"transformer_tr_features\"])\n",
"\n",
"raw_df[\"ci\"] = raw_df[\"ci\"].replace({\"True\": \"CI\", \"False\": \"CM\"})\n",
"raw_df[\"mode\"] = raw_df[\"regime\"] + \" \" + raw_df[\"ci\"]\n",
"raw_df[\"mode\"] = raw_df[\"mode\"].replace({\"global CI\": \"global\", \"global CM\": \"global\"})\n",
"raw_df.loc[\n",
" (raw_df['model'] == 'PyBoost') & (raw_df['mode'] == 'multivariate CI'),\n",
" 'mode'\n",
"] = 'multivariate CM'\n",
"raw_df = raw_df.drop(columns=[\"regime\", \"ci\"])\n",
"\n",
"raw_df = raw_df.drop_duplicates(subset=[\"model\", \"strategy_time\", \"datetime\", \"id\", \"transformer_name\", \"mode\", \"transformer_regime\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Value counts for each column\n",
"cols_for_check = [\n",
" col\n",
" for col in raw_df.columns\n",
" if col\n",
" not in [\n",
" \"mae_test\",\n",
" \"rmse_test\",\n",
" \"mape_test\",\n",
" \"fit_time_test\",\n",
" \"forecast_time_test\",\n",
" \"mae_val\",\n",
" \"rmse_val\",\n",
" \"mape_val\",\n",
" \"fit_time_val\",\n",
" \"forecast_time_val\",\n",
" ]\n",
"]\n",
"\n",
"for col in cols_for_check:\n",
" print(\"Column: \", col)\n",
" print(\"Type of data: \", raw_df[col].dtype)\n",
" \n",
" print(raw_df[col].value_counts(dropna=False))\n",
" print()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_df.to_csv(f\"{df_path[:-4]}_cleaned.csv\", index=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "py_3_10",
"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.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
82 changes: 82 additions & 0 deletions examples/all_configurations_benchmark/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
all_models_params = {
"ILI": {
"DLinear": {
"moving_avg": 25,
},
"PatchTST": {
"e_layers": 3,
"n_heads": 4,
"d_model": 16,
"d_ff": 128,
"dropout": 0.3,
"head_dropout": 0,
"patch_len": 24,
"stride": 2,
},
"GPT4TS": {
"d_model": 768,
"patch_len": 24,
"stride": 2,
"gpt_layers": 6,
"freeze": 1,
},
"TimesNet": {
"e_layers": 2,
"d_model": 768,
"d_ff": 768,
"top_k": 5,
},
"TimeMixer": {
"e_layers": 2,
"down_sampling_layers": 3,
"down_sampling_window": 2,
"d_model": 16,
"d_ff": 32,
"down_sampling_method": "avg",
},
"CycleNet": {
"model_type": 'linear',
"cycle_len": 24,
}
},
"ETTh1": {
"DLinear": {
"moving_avg": 25,
},
"PatchTST": {
"e_layers": 3,
"n_heads": 4,
"d_model": 16,
"d_ff": 128,
"dropout": 0.3,
"head_dropout": 0,
"patch_len": 16,
"stride": 8,
},
"GPT4TS": {
"d_model": 768,
"patch_len": 16,
"stride": 8,
"gpt_layers": 6,
"freeze": 1,
},
"TimesNet": {
"e_layers": 2,
"d_model": 16,
"d_ff": 32,
"top_k": 5,
},
"TimeMixer": {
"e_layers": 2,
"down_sampling_layers": 3,
"down_sampling_window": 2,
"d_model": 16,
"d_ff": 32,
"down_sampling_method": "avg",
},
"CycleNet": {
"model_type": 'linear',
"cycle_len": 24,
}
},
}
Loading