Skip to content

Commit

Permalink
update usage of plot_series and evaluate in docs (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Jul 23, 2024
1 parent 6271920 commit 66b8203
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 67 deletions.
4 changes: 2 additions & 2 deletions nbs/docs/getting-started/end_to_end_walkthrough.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@
"metadata": {},
"outputs": [],
"source": [
"fig = plot_series(cv_result, cv_result.drop(columns='cutoff'), max_insample_length=0)"
"fig = plot_series(forecasts_df=cv_result.drop(columns='cutoff'))"
]
},
{
Expand Down Expand Up @@ -2577,7 +2577,7 @@
"metadata": {},
"outputs": [],
"source": [
"fig = plot_series(cv.cv_preds_, cv.cv_preds_.drop(columns='window'), max_insample_length=0)"
"fig = plot_series(forecasts_df=cv.cv_preds_.drop(columns='window'))"
]
},
{
Expand Down
25 changes: 11 additions & 14 deletions nbs/docs/how-to-guides/cross_validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
"metadata": {},
"outputs": [],
"source": [
"crossvalidation_df = mlf.cross_validation(\n",
"cv_df = mlf.cross_validation(\n",
" df=Y_df,\n",
" h=24,\n",
" n_windows=3,\n",
Expand Down Expand Up @@ -425,7 +425,7 @@
}
],
"source": [
"crossvalidation_df.head()"
"cv_df.head()"
]
},
{
Expand Down Expand Up @@ -466,7 +466,7 @@
"metadata": {},
"outputs": [],
"source": [
"plot_cv(Y_df, crossvalidation_df, 'H1', '../../figs/cross_validation__predictions.png')"
"plot_cv(Y_df, cv_df, 'H1', '../../figs/cross_validation__predictions.png')"
]
},
{
Expand Down Expand Up @@ -503,16 +503,10 @@
"metadata": {},
"outputs": [],
"source": [
"from utilsforecast.evaluation import evaluate\n",
"from utilsforecast.losses import rmse "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll compute the `rmse` per time series and cutoff. To do this we'll concatenate the id and the cutoff columns, then we will take the mean of the results."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -522,14 +516,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE using cross-validation: 249.90517171185527\n"
"RMSE using cross-validation: 269.0\n"
]
}
],
"source": [
"crossvalidation_df['id_cutoff'] = crossvalidation_df['unique_id'] + '_' + crossvalidation_df['cutoff'].astype(str)\n",
"cv_rmse = rmse(crossvalidation_df, models=['LGBMRegressor'], id_col='id_cutoff')['LGBMRegressor'].mean()\n",
"print(\"RMSE using cross-validation: \", cv_rmse)"
"cv_rmse = evaluate(\n",
" cv_df.drop(columns='cutoff'),\n",
" metrics=[rmse],\n",
" agg_fn='mean',\n",
")\n",
"print(f\"RMSE using cross-validation: {cv_rmse['LGBMRegressor'].item():.1f}\")"
]
},
{
Expand Down
Binary file modified nbs/figs/cross_validation__predictions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/cross_validation__series.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__cv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__differences.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__eda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__final_forecast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__lgbcv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/end_to_end_walkthrough__predictions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__cross_validation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__cross_validation_intervals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__ercot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__predict.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__predict_intervals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified nbs/figs/forecast__predict_intervals_window_size_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 66b8203

Please sign in to comment.