%23%20%2F%2F%2F%20script%0A%23%20requires-python%20%3D%20%22%3E%3D3.11%22%0A%23%20dependencies%20%3D%20%5B%0A%23%20%20%20%20%20%22yohou%5Bplotting%5D%22%2C%0A%23%20%5D%0A%23%20%2F%2F%2F%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.23.8%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%0A%20%20%20%20from%20yohou.datasets%20import%20fetch_tourism_monthly%0A%20%20%20%20from%20yohou.interval%20import%20SplitConformalForecaster%0A%20%20%20%20from%20yohou.metrics%20import%20(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20%20%20%20%20MeanAbsolutePercentageError%2C%0A%20%20%20%20%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20)%0A%20%20%20%20from%20yohou.plotting%20import%20(%0A%20%20%20%20%20%20%20%20plot_calibration%2C%0A%20%20%20%20%20%20%20%20plot_group_scores%2C%0A%20%20%20%20%20%20%20%20plot_residuals%2C%0A%20%20%20%20%20%20%20%20plot_score_distribution%2C%0A%20%20%20%20%20%20%20%20plot_score_heatmap%2C%0A%20%20%20%20%20%20%20%20plot_score_per_step%2C%0A%20%20%20%20%20%20%20%20plot_score_per_vintage%2C%0A%20%20%20%20%20%20%20%20plot_score_summary%2C%0A%20%20%20%20%20%20%20%20plot_score_time_series%2C%0A%20%20%20%20)%0A%20%20%20%20from%20yohou.point%20import%20PointReductionForecaster%2C%20SeasonalNaive%0A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20%20%20%20%20MeanAbsolutePercentageError%2C%0A%20%20%20%20%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20%20%20%20%20SeasonalNaive%2C%0A%20%20%20%20%20%20%20%20SplitConformalForecaster%2C%0A%20%20%20%20%20%20%20%20fetch_tourism_monthly%2C%0A%20%20%20%20%20%20%20%20plot_calibration%2C%0A%20%20%20%20%20%20%20%20plot_group_scores%2C%0A%20%20%20%20%20%20%20%20plot_residuals%2C%0A%20%20%20%20%20%20%20%20plot_score_distribution%2C%0A%20%20%20%20%20%20%20%20plot_score_heatmap%2C%0A%20%20%20%20%20%20%20%20plot_score_per_step%2C%0A%20%20%20%20%20%20%20%20plot_score_per_vintage%2C%0A%20%20%20%20%20%20%20%20plot_score_summary%2C%0A%20%20%20%20%20%20%20%20plot_score_time_series%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Model%20Evaluation%20Plots%0A%0A%20%20%20%20**Prerequisites%3A**%20Familiarity%20with%20yohou's%20fit%2Fpredict%20API%20and%20scoring%20system%20(see%0A%20%20%20%20%60examples%2Fquickstart.py%60%20and%20%60examples%2Fscoring.py%60).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Prepare%20Models%20and%20Predictions%0A%0A%20%20%20%20We%20load%20the%20Monthly%20Tourism%20dataset%20via%20%5B%60fetch_tourism_monthly%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.datasets._fetchers.fetch_tourism_monthly%2F)%2C%20then%20fit%20two%0A%20%20%20%20point%20forecasters%3A%20%5B%60SeasonalNaive%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.point.naive.SeasonalNaive%2F)%20(repeats%20the%20last%20seasonal%20cycle)%20and%0A%20%20%20%20%5B%60PointReductionForecaster%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.point.reduction.PointReductionForecaster%2F)%20(uses%20an%20sklearn%20regressor%20with%20lag%20features).%0A%20%20%20%20Their%20predictions%20on%20the%20held-out%20test%20set%20are%20used%20throughout%20this%20notebook.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(PointReductionForecaster%2C%20SeasonalNaive%2C%20fetch_tourism_monthly)%3A%0A%20%20%20%20from%20yohou.model_selection%20import%20train_test_split%0A%0A%20%20%20%20tourism%20%3D%20(%0A%20%20%20%20%20%20%20%20fetch_tourism_monthly().frame.select(%22time%22%2C%20%22T1__tourists%22).drop_nulls().rename(%7B%22T1__tourists%22%3A%20%22tourists%22%7D)%0A%20%20%20%20)%0A%20%20%20%20fh%20%3D%2024%0A%20%20%20%20y_train%2C%20y_test%20%3D%20train_test_split(tourism%2C%20test_size%3Dfh)%0A%0A%20%20%20%20naive%20%3D%20SeasonalNaive(seasonality%3D12)%0A%20%20%20%20naive.fit(y_train%2C%20forecasting_horizon%3Dfh)%0A%20%20%20%20y_pred_naive%20%3D%20naive.predict(forecasting_horizon%3Dfh)%0A%0A%20%20%20%20reduction%20%3D%20PointReductionForecaster()%0A%20%20%20%20reduction.fit(y_train%2C%20forecasting_horizon%3Dfh)%0A%20%20%20%20y_pred_reduction%20%3D%20reduction.predict(forecasting_horizon%3Dfh)%0A%20%20%20%20return%20y_pred_naive%2C%20y_pred_reduction%2C%20y_test%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%201.%20Residual%20Diagnostics%0A%0A%20%20%20%20%5B%60plot_residuals%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_residuals%2F)%20creates%20a%204-panel%20layout%3A%20residuals%20over%20time%2C%0A%20%20%20%20residuals%20vs%20fitted%2C%20histogram%2C%20and%20Q-Q%20plot.%20Residuals%20are%20computed%0A%20%20%20%20internally%20as%20%60y_truth%20-%20y_pred%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_residuals%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_residuals(%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20title%3D%22Seasonal%20Naive%20-%20Residual%20Diagnostics%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_residuals%2C%20y_pred_reduction%2C%20y_test)%3A%0A%20%20%20%20plot_residuals(%0A%20%20%20%20%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20title%3D%22Reduction%20Forecaster%20-%20Residual%20Diagnostics%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_residuals%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_residuals(%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20columns%3D%22tourists%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Naive%20Residuals%20-%20Single%20Column%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%202.%20Score%20Time%20Series%0A%0A%20%20%20%20%5B%60plot_score_time_series%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_time_series%2F)%20evaluates%20per-timestep%20scorer%20values.%20Supports%0A%20%20%20%20single%20and%20multi-model%20comparisons%2C%20different%20scorers%2C%20and%20extensive%0A%20%20%20%20styling%20parameters.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_time_series%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_score_time_series(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Over%20Time%20-%20Seasonal%20Naive%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20plot_score_time_series%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_time_series(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Over%20Time%20-%20Model%20Comparison%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_time_series%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_time_series(%0A%20%20%20%20%20%20%20%20RootMeanSquaredError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20show_legend%3DTrue%2C%0A%20%20%20%20%20%20%20%20show_markers%3DTrue%2C%0A%20%20%20%20%20%20%20%20title%3D%22RMSE%20Over%20Time%20-%20With%20Markers%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_time_series%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_time_series(%0A%20%20%20%20%20%20%20%20%7B%22MAE%22%3A%20MeanAbsoluteError()%2C%20%22RMSE%22%3A%20RootMeanSquaredError()%7D%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20title%3D%22Multi-Scorer%20Over%20Time%20-%20Naive%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%203.%20Score%20Distribution%0A%0A%20%20%20%20%5B%60plot_score_distribution%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_distribution%2F)%20renders%20histograms%20(or%20KDE)%20of%20per-timestep%0A%20%20%20%20scores.%20Toggle%20**kind**%2C%20**show_mean**%2C%20**show_zero**%2C%20and%20**n_bins**.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_distribution%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_score_distribution(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22histogram%22%2C%0A%20%20%20%20%20%20%20%20n_bins%3D10%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Distribution%20-%20Histogram%20(default)%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_distribution%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_score_distribution(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22kde%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Distribution%20-%20KDE%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20plot_score_distribution%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_distribution(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22both%22%2C%0A%20%20%20%20%20%20%20%20n_bins%3D15%2C%0A%20%20%20%20%20%20%20%20show_mean%3DTrue%2C%0A%20%20%20%20%20%20%20%20show_zero%3DFalse%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Distribution%20-%20Both%2C%20Custom%20Bins%2C%20No%20Zero%20Line%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_distribution%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_distribution(%0A%20%20%20%20%20%20%20%20RootMeanSquaredError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22histogram%22%2C%0A%20%20%20%20%20%20%20%20n_bins%3D20%2C%0A%20%20%20%20%20%20%20%20title%3D%22RMSE%20Distribution%20-%2020%20Bins%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_distribution%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_distribution(%0A%20%20%20%20%20%20%20%20%7B%22MAE%22%3A%20MeanAbsoluteError()%2C%20%22RMSE%22%3A%20RootMeanSquaredError()%7D%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22histogram%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Multi-Scorer%20Distribution%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%204.%20Score%20per%20Horizon%0A%0A%20%20%20%20%5B%60plot_score_per_step%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_per_step%2F)%20shows%20how%20forecast%20quality%20degrades%20at%20each%0A%20%20%20%20step%20of%20the%20prediction%20window.%20Switch%20between%20**line**%20and%20**bar**%0A%20%20%20%20kind%2C%20and%20overlay%20a%20**trend**%20line.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_per_step%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_score_per_step(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22line%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20by%20Horizon%20-%20Line%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_per_step%2C%20y_pred_naive%2C%20y_test)%3A%0A%20%20%20%20plot_score_per_step(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22bar%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20by%20Horizon%20-%20Bar%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20plot_score_per_step%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_per_step(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22line%22%2C%0A%20%20%20%20%20%20%20%20show_trend%3DTrue%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20by%20Horizon%20-%20Multi-Model%20with%20Trend%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_per_step%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_per_step(%0A%20%20%20%20%20%20%20%20RootMeanSquaredError()%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22bar%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22RMSE%20by%20Horizon%20-%20Bar%20Comparison%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%205.%20Model%20Comparison%20Summary%0A%0A%20%20%20%20%5B%60plot_score_summary%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_summary%2F)%20produces%20a%0A%20%20%20%20grouped%20bar%20chart%20that%20collapses%20horizon%20steps%20into%20a%20single%20aggregate%0A%20%20%20%20score%20per%20model%20per%20scorer.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20MeanAbsolutePercentageError%2C%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_summary%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_summary(%0A%20%20%20%20%20%20%20%20%7B%22MAE%22%3A%20MeanAbsoluteError()%2C%20%22RMSE%22%3A%20RootMeanSquaredError()%2C%20%22MAPE%22%3A%20MeanAbsolutePercentageError()%7D%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20title%3D%22Model%20Comparison%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20MeanAbsolutePercentageError%2C%0A%20%20%20%20RootMeanSquaredError%2C%0A%20%20%20%20plot_score_summary%2C%0A%20%20%20%20y_pred_naive%2C%0A%20%20%20%20y_pred_reduction%2C%0A%20%20%20%20y_test%2C%0A)%3A%0A%20%20%20%20plot_score_summary(%0A%20%20%20%20%20%20%20%20%7B%22MAE%22%3A%20MeanAbsoluteError()%2C%20%22RMSE%22%3A%20RootMeanSquaredError()%2C%20%22MAPE%22%3A%20MeanAbsolutePercentageError()%7D%2C%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_naive%2C%20%22Reduction%22%3A%20y_pred_reduction%7D%2C%0A%20%20%20%20%20%20%20%20sort_ascending%3DTrue%2C%0A%20%20%20%20%20%20%20%20title%3D%22Model%20Comparison%20-%20Sorted%20Ascending%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%206.%20Calibration%20Plot%0A%0A%20%20%20%20%5B%60plot_calibration%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_calibration%2F)%20compares%20nominal%20coverage%20rates%20(the%20requested%20interval%0A%20%20%20%20widths)%20against%20empirical%20coverage%20(the%20fraction%20of%20test%20points%20actually%0A%20%20%20%20falling%20inside%20each%20interval).%20Points%20near%20the%20diagonal%20indicate%20that%20the%0A%20%20%20%20interval%20forecaster's%20uncertainty%20estimates%20are%20well%20calibrated.%20A%0A%20%20%20%20%5B%60SplitConformalForecaster%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.interval.split_conformal.SplitConformalForecaster%2F)%20wrapping%20%5B%60SeasonalNaive%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.point.naive.SeasonalNaive%2F)%20generates%20the%0A%20%20%20%20prediction%20intervals%20used%20here.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(SeasonalNaive%2C%20SplitConformalForecaster%2C%20fetch_tourism_monthly)%3A%0A%20%20%20%20tourism_calib%20%3D%20(%0A%20%20%20%20%20%20%20%20fetch_tourism_monthly().frame.select(%22time%22%2C%20%22T1__tourists%22).drop_nulls().rename(%7B%22T1__tourists%22%3A%20%22tourists%22%7D)%0A%20%20%20%20)%0A%20%20%20%20fh_calib%20%3D%2012%0A%20%20%20%20y_train_calib%20%3D%20tourism_calib.head(len(tourism_calib)%20-%20fh_calib)%0A%20%20%20%20y_test_calib%20%3D%20tourism_calib.tail(fh_calib)%0A%0A%20%20%20%20conformal_calib%20%3D%20SplitConformalForecaster(%0A%20%20%20%20%20%20%20%20point_forecaster%3DSeasonalNaive(seasonality%3D12)%2C%0A%20%20%20%20)%0A%20%20%20%20conformal_calib.fit(y_train_calib%2C%20forecasting_horizon%3Dfh_calib)%0A%0A%20%20%20%20coverage_rates%20%3D%20%5B0.1%2C%200.2%2C%200.3%2C%200.4%2C%200.5%2C%200.8%2C%200.9%2C%200.95%5D%0A%20%20%20%20y_pred_calib%20%3D%20conformal_calib.predict_interval(%0A%20%20%20%20%20%20%20%20forecasting_horizon%3Dfh_calib%2C%0A%20%20%20%20%20%20%20%20coverage_rates%3Dcoverage_rates%2C%0A%20%20%20%20)%0A%20%20%20%20return%20coverage_rates%2C%20y_pred_calib%2C%20y_test_calib%0A%0A%0A%40app.cell%0Adef%20_(coverage_rates%2C%20plot_calibration%2C%20y_pred_calib%2C%20y_test_calib)%3A%0A%20%20%20%20plot_calibration(%0A%20%20%20%20%20%20%20%20y_pred_calib%2C%0A%20%20%20%20%20%20%20%20y_test_calib%2C%0A%20%20%20%20%20%20%20%20coverage_rates%3Dcoverage_rates%2C%0A%20%20%20%20%20%20%20%20columns%3D%22tourists%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Calibration%20-%20Multiple%20Coverage%20Rates%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_calibration%2C%20y_pred_calib%2C%20y_test_calib)%3A%0A%20%20%20%20plot_calibration(%0A%20%20%20%20%20%20%20%20y_pred_calib%2C%0A%20%20%20%20%20%20%20%20y_test_calib%2C%0A%20%20%20%20%20%20%20%20coverage_rates%3D%5B0.5%2C%200.8%2C%200.9%2C%200.95%5D%2C%0A%20%20%20%20%20%20%20%20columns%3D%22tourists%22%2C%0A%20%20%20%20%20%20%20%20x_label%3D%22Nominal%22%2C%0A%20%20%20%20%20%20%20%20y_label%3D%22Empirical%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Calibration%20-%20Custom%20Axis%20Labels%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_calibration%2C%20y_pred_calib%2C%20y_test_calib)%3A%0A%20%20%20%20plot_calibration(%0A%20%20%20%20%20%20%20%20y_pred_calib%2C%0A%20%20%20%20%20%20%20%20y_test_calib%2C%0A%20%20%20%20%20%20%20%20coverage_rates%3D%5B0.5%2C%200.8%2C%200.9%2C%200.95%5D%2C%0A%20%20%20%20%20%20%20%20columns%3D%22tourists%22%2C%0A%20%20%20%20%20%20%20%20reference_dash%3D%22dot%22%2C%0A%20%20%20%20%20%20%20%20reference_color%3D%22%236366f1%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Calibration%20-%20Custom%20Reference%20Line%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%207.%20Score%20per%20Vintage%0A%0A%20%20%20%20%5B%60plot_score_per_vintage%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_per_vintage%2F)%20tracks%20how%20forecast%20accuracy%20evolves%20across%0A%20%20%20%20successive%20forecast%20origins%20(vintages).%20This%20requires%20multi-vintage%20predictions%0A%20%20%20%20produced%20by%20%5B%60observe_predict%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.point.reduction.PointReductionForecaster.observe_predict%2F).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(SeasonalNaive%2C%20fetch_tourism_monthly)%3A%0A%20%20%20%20from%20copy%20import%20deepcopy%0A%0A%20%20%20%20tourism_v%20%3D%20(%0A%20%20%20%20%20%20%20%20fetch_tourism_monthly().frame.select(%22time%22%2C%20%22T1__tourists%22).drop_nulls().rename(%7B%22T1__tourists%22%3A%20%22tourists%22%7D)%0A%20%20%20%20)%0A%20%20%20%20fh_v%20%3D%2012%0A%20%20%20%20y_train_v%20%3D%20tourism_v.head(len(tourism_v)%20-%20fh_v)%0A%20%20%20%20y_test_v%20%3D%20tourism_v.tail(fh_v)%0A%0A%20%20%20%20naive_v%20%3D%20SeasonalNaive(seasonality%3D12)%0A%20%20%20%20naive_v.fit(y_train_v%2C%20forecasting_horizon%3Dfh_v)%0A%20%20%20%20y_pred_v%20%3D%20deepcopy(naive_v).observe_predict(y_test_v%2C%20forecasting_horizon%3Dfh_v%2C%20stride%3D1)%0A%20%20%20%20return%20y_pred_v%2C%20y_test_v%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_per_vintage%2C%20y_pred_v%2C%20y_test_v)%3A%0A%20%20%20%20plot_score_per_vintage(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_v%2C%0A%20%20%20%20%20%20%20%20y_pred_v%2C%0A%20%20%20%20%20%20%20%20kind%3D%22line%22%2C%0A%20%20%20%20%20%20%20%20show_trend%3DTrue%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20per%20Vintage%20-%20Line%20with%20Trend%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_per_vintage%2C%20y_pred_v%2C%20y_test_v)%3A%0A%20%20%20%20plot_score_per_vintage(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_v%2C%0A%20%20%20%20%20%20%20%20y_pred_v%2C%0A%20%20%20%20%20%20%20%20kind%3D%22bar%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20per%20Vintage%20-%20Bar%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%208.%20Score%20Heatmap%0A%0A%20%20%20%20%5B%60plot_score_heatmap%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_score_heatmap%2F)%20renders%20a%202D%20heatmap%20showing%20scores%20across%20two%0A%20%20%20%20forecast%20dimensions%20(e.g.%20horizon%20step%20vs%20vintage).%20Each%20cell%20encodes%0A%20%20%20%20the%20score%20for%20that%20specific%20combination%2C%20revealing%20patterns%20such%20as%0A%20%20%20%20accuracy%20degrading%20at%20longer%20horizons%20or%20later%20vintages.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_score_heatmap%2C%20y_pred_v%2C%20y_test_v)%3A%0A%20%20%20%20plot_score_heatmap(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_v%2C%0A%20%20%20%20%20%20%20%20y_pred_v%2C%0A%20%20%20%20%20%20%20%20x_dim%3D%22step%22%2C%0A%20%20%20%20%20%20%20%20y_dim%3D%22vintage%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22MAE%20Heatmap%20-%20Step%20vs%20Vintage%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%209.%20Group%20Scores%0A%0A%20%20%20%20%5B%60plot_group_scores%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.evaluation.plot_group_scores%2F)%20breaks%20down%20scorer%20performance%20by%20panel%20group%0A%20%20%20%20(columns%20with%20%60%60group__member%60%60%20naming).%20Supports%20%60kind%3D%22bar%22%60%20for%0A%20%20%20%20aggregate%20comparisons%2C%20%60kind%3D%22box%22%60%20for%20score%20distributions%2C%20and%0A%20%20%20%20%60kind%3D%22heatmap%22%60%20for%20a%202D%20overview.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(PointReductionForecaster%2C%20SeasonalNaive%2C%20fetch_tourism_monthly)%3A%0A%20%20%20%20tourism_panel%20%3D%20fetch_tourism_monthly(n_series%3D4).frame.drop_nulls()%0A%20%20%20%20fh_panel%20%3D%2012%0A%20%20%20%20y_train_panel%20%3D%20tourism_panel.head(len(tourism_panel)%20-%20fh_panel)%0A%20%20%20%20y_test_panel%20%3D%20tourism_panel.tail(fh_panel)%0A%0A%20%20%20%20naive_panel%20%3D%20SeasonalNaive(seasonality%3D12)%0A%20%20%20%20naive_panel.fit(y_train_panel%2C%20forecasting_horizon%3Dfh_panel)%0A%20%20%20%20y_pred_panel_naive%20%3D%20naive_panel.predict(forecasting_horizon%3Dfh_panel)%0A%0A%20%20%20%20red_panel%20%3D%20PointReductionForecaster()%0A%20%20%20%20red_panel.fit(y_train_panel%2C%20forecasting_horizon%3Dfh_panel)%0A%20%20%20%20y_pred_panel_red%20%3D%20red_panel.predict(forecasting_horizon%3Dfh_panel)%0A%20%20%20%20return%20y_pred_panel_naive%2C%20y_pred_panel_red%2C%20y_test_panel%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20plot_group_scores%2C%0A%20%20%20%20y_pred_panel_naive%2C%0A%20%20%20%20y_pred_panel_red%2C%0A%20%20%20%20y_test_panel%2C%0A)%3A%0A%20%20%20%20plot_group_scores(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_panel%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_panel_naive%2C%20%22Reduction%22%3A%20y_pred_panel_red%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22bar%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Groupwise%20MAE%20-%20Bar%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_group_scores%2C%20y_pred_panel_naive%2C%20y_test_panel)%3A%0A%20%20%20%20plot_group_scores(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_panel%2C%0A%20%20%20%20%20%20%20%20y_pred_panel_naive%2C%0A%20%20%20%20%20%20%20%20kind%3D%22box%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Groupwise%20MAE%20Distribution%20-%20Box%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20plot_group_scores%2C%0A%20%20%20%20y_pred_panel_naive%2C%0A%20%20%20%20y_pred_panel_red%2C%0A%20%20%20%20y_test_panel%2C%0A)%3A%0A%20%20%20%20plot_group_scores(%0A%20%20%20%20%20%20%20%20MeanAbsoluteError()%2C%0A%20%20%20%20%20%20%20%20y_test_panel%2C%0A%20%20%20%20%20%20%20%20%7B%22Naive%22%3A%20y_pred_panel_naive%2C%20%22Reduction%22%3A%20y_pred_panel_red%7D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22heatmap%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Groupwise%20MAE%20-%20Heatmap%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Next%20Steps%0A%0A%20%20%20%20-%20**Forecasting**%3A%20See%20%5B%60examples%2Fplotting%2Fforecasting_visualization.py%60%5D(%2Fexamples%2Fvisualization%2Fforecasting_visualization%2F)%20for%20forecast%20plots%2C%20intervals%2C%20and%20comparison%20modes%0A%20%20%20%20-%20**Cross-validation**%3A%20See%20%5B%60examples%2Fplotting%2Fmodel_selection.py%60%5D(%2Fexamples%2Fvisualization%2Fmodel_selection%2F)%20for%20train%2Ftest%20split%20visualization%0A%20%20%20%20-%20**Similarity**%3A%20See%20%60examples%2Fplotting%2Fsimilarity_heatmap.py%60%20for%20distance-based%20interval%20weights%0A%20%20%20%20-%20**Signal%20processing**%3A%20See%20%5B%60examples%2Fplotting%2Fsignal_processing.py%60%5D(%2Fexamples%2Fvisualization%2Fsignal_processing%2F)%20for%20spectrum%20and%20phase%20analysis%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
a1cdf47e7c6ed9d04e7f82babf5fa633