Skip to content

Commit

Permalink
[DOCS] Fix examples (#1092)
Browse files Browse the repository at this point in the history
* fix_examples

* comments_marco_and_slack_comment_on_default_config_auto_models

* fix_mint
  • Loading branch information
elephaint authored Jul 30, 2024
1 parent afc1da9 commit 926937a
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 1,060 deletions.
2 changes: 1 addition & 1 deletion nbs/docs/capabilities/01_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"|`TCN` | `AutoTCN` | CNN | Univariate | Recursive | F/H/S | \n",
"|`TFT` | `AutoTFT` | Transformer | Univariate | Direct | F/H/S | \n",
"|`TiDE` | `AutoTiDE` | MLP | Univariate | Direct | F/H/S | \n",
"|`TimeMixer` | `AutoTimeMixer` | MLP | Multivariate | Direct | F | \n",
"|`TimeMixer` | `AutoTimeMixer` | MLP | Multivariate | Direct | - | \n",
"|`TimeLLM` | - | LLM | Univariate | Direct | - | \n",
"|`TimesNet` | `AutoTimesNet` | CNN | Univariate | Direct | F | \n",
"|`TSMixer` | `AutoTSMixer` | MLP | Multivariate | Direct | - | \n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"docs/tutorials/temporal_classification.html",
"docs/tutorials/transfer_learning.html",
"docs/tutorials/adding_models.html",
"docs/tutorials/large_datasets_tutorial.html"
"docs/tutorials/large_datasets.html"
]
}
]
Expand Down
8 changes: 2 additions & 6 deletions nbs/models.autoformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -693,16 +693,12 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import MLP\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"from neuralforecast.models import Autoformer\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"\n",
"AirPassengersPanel, calendar_cols = augment_calendar_df(df=AirPassengersPanel, freq='M')\n",
"\n",
Expand Down
17 changes: 5 additions & 12 deletions nbs/models.bitcn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,15 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"#| eval: false\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.losses.pytorch import GMM, DistributionLoss\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from neuralforecast.models import BiTCN\n",
"from neuralforecast.losses.pytorch import GMM\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic\n",
"\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
"\n",
Expand Down
29 changes: 3 additions & 26 deletions nbs/models.deepar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,6 @@
"## Usage Example"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss, GMM, PMM\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -621,16 +609,13 @@
"source": [
"#| eval: false\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"#from neuralforecast.models import DeepAR\n",
"from neuralforecast.losses.pytorch import DistributionLoss, HuberMQLoss\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic\n",
"from neuralforecast.models import DeepAR\n",
"from neuralforecast.losses.pytorch import DistributionLoss\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic\n",
"\n",
"#AirPassengersPanel['y'] = AirPassengersPanel['y'] + 10\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
"\n",
Expand Down Expand Up @@ -661,7 +646,6 @@
"\n",
"plot_df = plot_df[plot_df.unique_id=='Airline1'].drop('unique_id', axis=1)\n",
"plt.plot(plot_df['ds'], plot_df['y'], c='black', label='True')\n",
"#plt.plot(plot_df['ds'], plot_df['DeepAR'], c='purple', label='mean')\n",
"plt.plot(plot_df['ds'], plot_df['DeepAR-median'], c='blue', label='median')\n",
"plt.fill_between(x=plot_df['ds'][-12:], \n",
" y1=plot_df['DeepAR-lo-90'][-12:].values, \n",
Expand All @@ -671,13 +655,6 @@
"plt.grid()\n",
"plt.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
13 changes: 4 additions & 9 deletions nbs/models.deepnpts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,14 @@
"metadata": {},
"outputs": [],
"source": [
"#| eval: false\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from neuralforecast.models import DeepNPTS\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic\n",
"\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
"\n",
Expand Down
12 changes: 1 addition & 11 deletions nbs/models.dilated_rnn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,13 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import DilatedRNN\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss\n",
"from neuralforecast.losses.pytorch import DistributionLoss\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic\n",
"from neuralforecast.tsdataset import TimeSeriesDataset, TimeSeriesLoader\n",
"\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
Expand Down Expand Up @@ -611,13 +608,6 @@
"plt.grid()\n",
"plt.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
16 changes: 2 additions & 14 deletions nbs/models.dlinear.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,12 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import MLP\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"from neuralforecast.models import DLinear\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"\n",
"AirPassengersPanel, calendar_cols = augment_calendar_df(df=AirPassengersPanel, freq='M')\n",
"\n",
Expand All @@ -334,7 +330,6 @@
"model = DLinear(h=12,\n",
" input_size=24,\n",
" loss=MAE(),\n",
" #loss=DistributionLoss(distribution='StudentT', level=[80, 90], return_params=True),\n",
" scaler_type='robust',\n",
" learning_rate=1e-3,\n",
" max_steps=500,\n",
Expand Down Expand Up @@ -370,13 +365,6 @@
" plt.legend()\n",
" plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
20 changes: 4 additions & 16 deletions nbs/models.fedformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -697,30 +697,18 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import MLP\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss, MSE\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"from neuralforecast.models import FEDformer\n",
"from neuralforecast.utils import AirPassengersPanel, augment_calendar_df\n",
"\n",
"AirPassengersPanel, calendar_cols = augment_calendar_df(df=AirPassengersPanel, freq='M')\n",
"\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| eval: false\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
"\n",
"model = FEDformer(h=12,\n",
" input_size=24,\n",
" modes=64,\n",
Expand Down
12 changes: 1 addition & 11 deletions nbs/models.gru.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,13 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import GRU\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss\n",
"from neuralforecast.losses.pytorch import DistributionLoss\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic\n",
"from neuralforecast.tsdataset import TimeSeriesDataset, TimeSeriesLoader\n",
"\n",
"Y_train_df = AirPassengersPanel[AirPassengersPanel.ds<AirPassengersPanel['ds'].values[-12]] # 132 train\n",
"Y_test_df = AirPassengersPanel[AirPassengersPanel.ds>=AirPassengersPanel['ds'].values[-12]].reset_index(drop=True) # 12 test\n",
Expand Down Expand Up @@ -364,13 +361,6 @@
"plt.grid()\n",
"plt.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
1 change: 0 additions & 1 deletion nbs/models.hint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast.losses.pytorch import GMM, sCRPS\n",
Expand Down
9 changes: 2 additions & 7 deletions nbs/models.informer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,12 @@
"outputs": [],
"source": [
"#| eval: false\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pytorch_lightning as pl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from neuralforecast import NeuralForecast\n",
"from neuralforecast.models import MLP\n",
"from neuralforecast.losses.pytorch import MQLoss, DistributionLoss\n",
"from neuralforecast.tsdataset import TimeSeriesDataset\n",
"from neuralforecast.utils import AirPassengers, AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"from neuralforecast.models import Informer\n",
"from neuralforecast.utils import AirPassengersPanel, AirPassengersStatic, augment_calendar_df\n",
"\n",
"AirPassengersPanel, calendar_cols = augment_calendar_df(df=AirPassengersPanel, freq='M')\n",
"\n",
Expand All @@ -552,7 +548,6 @@
" hidden_size = 16,\n",
" conv_hidden_size = 32,\n",
" n_head = 2,\n",
" #loss=DistributionLoss(distribution='StudentT', level=[80, 90]),\n",
" loss=MAE(),\n",
" futr_exog_list=calendar_cols,\n",
" scaler_type='robust',\n",
Expand Down
Loading

0 comments on commit 926937a

Please sign in to comment.