Skip to content

Commit

Permalink
Isolated import cells [Issue #653] (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dd authored Nov 10, 2023
1 parent 855a621 commit 1a84462
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 160 deletions.
13 changes: 12 additions & 1 deletion nbs/src/adapters.prophet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@
"source": [
"#| hide\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)\n",
"\n",
"from nbdev.showdoc import show_doc"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#| hide\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
15 changes: 13 additions & 2 deletions nbs/src/arima.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@
"outputs": [],
"source": [
"#| hide\n",
"import warnings\n",
"warnings.simplefilter('ignore')"
"import warnings"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#| hide\n",
"warnings.simplefilter('ignore')\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"id": "bb0efd1a",
Expand Down
13 changes: 12 additions & 1 deletion nbs/src/ces.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,18 @@
" return model"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#| hide\n",
"import matplotlib.pyplot as plt"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -1153,7 +1165,6 @@
"outputs": [],
"source": [
"#| hide\n",
"import matplotlib.pyplot as plt\n",
"res = auto_ces(ap, m=12, model='F')\n",
"fcst = forecast_ces(res, 12)\n",
"plt.plot(np.arange(0, len(ap)), ap)\n",
Expand Down
90 changes: 73 additions & 17 deletions nbs/src/core/core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,24 @@
"source": [
"#| hide\n",
"import warnings\n",
"warnings.filterwarnings('ignore', category=FutureWarning)\n",
"warnings.filterwarnings('always', category=UserWarning)\n",
"\n",
"from nbdev.showdoc import add_docs, show_doc\n",
"from statsforecast.models import Naive"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#| hide\n",
"warnings.filterwarnings('ignore', category=FutureWarning)\n",
"warnings.filterwarnings('always', category=UserWarning)\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -2268,12 +2279,21 @@
" DynamicOptimizedTheta,\n",
" AutoETS,\n",
" AutoCES\n",
")\n",
"\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# Generate synthetic panel DataFrame for example\n",
"panel_df = generate_series(n_series=9, equal_ends=False, engine='pandas')\n",
"panel_df.groupby('unique_id').tail(4)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -2677,8 +2697,14 @@
"\n",
"#from statsforecast.core import StatsForecast\n",
"from statsforecast.utils import AirPassengersDF as panel_df\n",
"from statsforecast.models import AutoARIMA, Naive\n",
"\n",
"from statsforecast.models import AutoARIMA, Naive\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# Instantiate StatsForecast class\n",
"fcst = StatsForecast(df=panel_df,\n",
" models=[AutoARIMA(), Naive()],\n",
Expand All @@ -2687,7 +2713,10 @@
"# Efficiently predict without storing memory\n",
"fcsts_df = fcst.forecast(h=4, fitted=True)\n",
"fcsts_df.groupby('unique_id').tail(4)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -2812,8 +2841,14 @@
"\n",
"#from statsforecast.core import StatsForecast\n",
"from statsforecast.utils import AirPassengersDF as panel_df\n",
"from statsforecast.models import Naive\n",
"\n",
"from statsforecast.models import Naive\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# Instantiate StatsForecast class\n",
"fcst = StatsForecast(df=panel_df,\n",
" models=[AutoARIMA()],\n",
Expand All @@ -2823,7 +2858,10 @@
"fcsts_df = fcst.forecast(h=12, fitted=True, level=(90, 10))\n",
"insample_fcsts_df = fcst.forecast_fitted_values()\n",
"insample_fcsts_df.tail(4)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -2910,8 +2948,14 @@
"\n",
"#from statsforecast.core import StatsForecast\n",
"from statsforecast.utils import AirPassengersDF as panel_df\n",
"from statsforecast.models import Naive\n",
"\n",
"from statsforecast.models import Naive\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# Instantiate StatsForecast class\n",
"fcst = StatsForecast(df=panel_df,\n",
" models=[Naive()],\n",
Expand All @@ -2920,7 +2964,10 @@
"# Access insample predictions\n",
"rolled_fcsts_df = fcst.cross_validation(14, n_windows=2)\n",
"rolled_fcsts_df.head(4)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -3097,8 +3144,14 @@
"\n",
"#from statsforecast.core import StatsForecast\n",
"from statsforecast.utils import AirPassengersDF as panel_df\n",
"from statsforecast.models import Naive\n",
"\n",
"from statsforecast.models import Naive\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# Instantiate StatsForecast class\n",
"fcst = StatsForecast(df=panel_df,\n",
" models=[Naive()],\n",
Expand All @@ -3108,7 +3161,10 @@
"rolled_fcsts_df = fcst.cross_validation(h=12, n_windows=2, fitted=True)\n",
"insample_rolled_fcsts_df = fcst.cross_validation_fitted_values()\n",
"insample_rolled_fcsts_df.tail(4)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down
Loading

0 comments on commit 1a84462

Please sign in to comment.