Skip to content

Instantly share code, notes, and snippets.

@gumdropsteve
Last active October 1, 2020 14:29
Show Gist options
  • Save gumdropsteve/770d254955bef0e43d756b2de9048c2d to your computer and use it in GitHub Desktop.
Save gumdropsteve/770d254955bef0e43d756b2de9048c2d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**With Dask**"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:fbprophet:Making 17 forecasts with cutoffs between 2011-01-02 00:00:00 and 2018-12-31 00:00:00\n",
"INFO:fbprophet:Applying in parallel with <Client: 'tcp://127.0.0.1:54456' processes=4 threads=8, memory=8.42 GB>\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Wall time: 42.2 s\n"
]
}
],
"source": [
"%%time\n",
"df_cv = cross_validation(m, \n",
" horizon=\"365 days\",\n",
" period=\"182.5 days\", \n",
" initial=\"730 days\", \n",
" parallel=\"dask\"\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Default (None)**"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:fbprophet:Making 17 forecasts with cutoffs between 2011-01-02 00:00:00 and 2018-12-31 00:00:00\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d1855c04bf3c45d391c56b6e03c62dea",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, max=17.0), HTML(value='')))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Wall time: 1min 19s\n"
]
}
],
"source": [
"%%time\n",
"df_cv = cross_validation(m, \n",
" horizon=\"365 days\",\n",
" period=\"182.5 days\", \n",
" initial=\"730 days\", \n",
" parallel=None\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>horizon</th>\n",
" <th>mse</th>\n",
" <th>rmse</th>\n",
" <th>mae</th>\n",
" <th>mape</th>\n",
" <th>mdape</th>\n",
" <th>coverage</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>365 days</td>\n",
" <td>0.014634</td>\n",
" <td>0.120972</td>\n",
" <td>0.093177</td>\n",
" <td>0.031736</td>\n",
" <td>0.026003</td>\n",
" <td>0.705778</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" horizon mse rmse mae mape mdape coverage\n",
"0 365 days 0.014634 0.120972 0.093177 0.031736 0.026003 0.705778"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from fbprophet.diagnostics import performance_metrics\n",
"\n",
"performance_metrics(df_cv, rolling_window=1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment