%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%22scikit-learn%22%2C%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_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Reduction%20Forecasting%20with%20sklearn%0A%0A%20%20%20%20This%20notebook%20demonstrates%20**reduction%20forecasting**%20-%20the%20approach%20of%20converting%0A%20%20%20%20time%20series%20forecasting%20into%20a%20supervised%20learning%20problem%20that%20sklearn%20regressors%0A%20%20%20%20can%20solve.%0A%0A%20%20%20%20%23%23%20Prerequisites%0A%0A%20%20%20%20Basic%20familiarity%20with%20sklearn's%20fit%2Fpredict%20API%20and%20time%20series%20concepts%20(trend%2C%20seasonality).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20from%20sklearn.linear_model%20import%20Ridge%0A%0A%20%20%20%20from%20yohou.datasets%20import%20fetch_tourism_monthly%0A%20%20%20%20from%20yohou.metrics%20import%20MeanAbsoluteError%0A%20%20%20%20from%20yohou.model_selection%20import%20ExpandingWindowSplitter%2C%20GridSearchCV%2C%20train_test_split%0A%20%20%20%20from%20yohou.plotting%20import%20(%0A%20%20%20%20%20%20%20%20plot_cv_results_scatter%2C%0A%20%20%20%20%20%20%20%20plot_forecast%2C%0A%20%20%20%20%20%20%20%20plot_seasonality%2C%0A%20%20%20%20%20%20%20%20plot_time_series%2C%0A%20%20%20%20)%0A%20%20%20%20from%20yohou.point%20import%20PointReductionForecaster%0A%20%20%20%20from%20yohou.preprocessing%20import%20LagTransformer%0A%20%20%20%20from%20yohou.stationarity%20import%20LogTransformer%0A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20ExpandingWindowSplitter%2C%0A%20%20%20%20%20%20%20%20GridSearchCV%2C%0A%20%20%20%20%20%20%20%20LagTransformer%2C%0A%20%20%20%20%20%20%20%20LogTransformer%2C%0A%20%20%20%20%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20%20%20%20%20Ridge%2C%0A%20%20%20%20%20%20%20%20fetch_tourism_monthly%2C%0A%20%20%20%20%20%20%20%20plot_cv_results_scatter%2C%0A%20%20%20%20%20%20%20%20plot_forecast%2C%0A%20%20%20%20%20%20%20%20plot_seasonality%2C%0A%20%20%20%20%20%20%20%20plot_time_series%2C%0A%20%20%20%20%20%20%20%20train_test_split%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%23%201.%20Load%20and%20Explore%20the%20Data%0A%0A%20%20%20%20We%20use%20the%20Monthly%20Tourism%20dataset%20-%20monthly%20tourist%20counts.%0A%20%20%20%20It%20exhibits%20strong%20trend%20and%20seasonality%2C%20making%20it%20ideal%20for%0A%20%20%20%20demonstrating%20preprocessing%20techniques.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(fetch_tourism_monthly)%3A%0A%20%20%20%20y%20%3D%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%0A%20%20%20%20print(f%22Dataset%3A%20%7Blen(y)%7D%20observations%20from%20%7By%5B'time'%5D.min()%7D%20to%20%7By%5B'time'%5D.max()%7D%22)%0A%20%20%20%20y.head()%0A%20%20%20%20return%20(y%2C)%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%5B%60plot_time_series%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.exploration.plot_time_series%2F)%20shows%20the%20raw%20data%2C%20and%20%5B%60plot_seasonality%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.diagnostics.plot_seasonality%2F)%20overlays%20each%0A%20%20%20%20year's%20monthly%20values%20on%20the%20same%20seasonal%20axis%20(FPP3%20gg_season%20style)%20to%0A%20%20%20%20reveal%20the%20repeating%20yearly%20pattern.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_time_series%2C%20y)%3A%0A%20%20%20%20plot_time_series(y%2C%20title%3D%22Monthly%20Tourism%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_seasonality%2C%20y)%3A%0A%20%20%20%20plot_seasonality(y%2C%20seasonality%3D%22month%22%2C%20title%3D%22Monthly%20Seasonality%20Pattern%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%202.%20Train%2FTest%20Split%0A%0A%20%20%20%20For%20time%20series%2C%20we%20must%20preserve%20temporal%20order%20-%20no%20shuffling%20allowed.%0A%20%20%20%20We%20hold%20out%20the%20last%20~20%25%20(29%20months)%20for%20testing.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(train_test_split%2C%20y)%3A%0A%20%20%20%20y_train%2C%20y_test%20%3D%20train_test_split(y%2C%20test_size%3D0.2)%0A%20%20%20%20forecasting_horizon%20%3D%2012%0A%0A%20%20%20%20print(f%22Training%3A%20%7Blen(y_train)%7D%20obs%20(%7By_train%5B'time'%5D.min()%7D%20to%20%7By_train%5B'time'%5D.max()%7D)%22)%0A%20%20%20%20print(f%22Test%3A%20%7Blen(y_test)%7D%20obs%20(%7By_test%5B'time'%5D.min()%7D%20to%20%7By_test%5B'time'%5D.max()%7D)%22)%0A%20%20%20%20return%20forecasting_horizon%2C%20y_test%2C%20y_train%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.%20Basic%20Reduction%20Forecaster%0A%0A%20%20%20%20%5B%60PointReductionForecaster%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.point.reduction.PointReductionForecaster%2F)%20converts%20time%20series%20forecasting%20into%20tabular%20regression%3A%0A%0A%20%20%20%201.%20**Feature%20generation**%3A%20%60feature_transformer%60%20creates%20lag%20features%20from%20past%20y%20values%0A%20%20%20%202.%20**Fit**%3A%20Trains%20an%20sklearn%20regressor%20on%20the%20(lags%2C%20y)%20tabular%20data%0A%20%20%20%203.%20**Predict**%3A%20Recursively%20forecasts%20by%20feeding%20predictions%20back%20as%20features%0A%0A%20%20%20%20Key%20distinction%3A%0A%20%20%20%20-%20**%60feature_transformer%60**%3A%20Generates%20input%20features%20from%20y%20(e.g.%2C%20%5B%60LagTransformer%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.preprocessing.window.LagTransformer%2F)%20for%20lags)%20-%20not%20invertible%0A%20%20%20%20-%20**%60target_transformer%60**%3A%20Applied%20to%20y%20before%20fitting%2C%20inverted%20after%20prediction%20(e.g.%2C%20%5B%60LogTransformer%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.stationarity.transformers.LogTransformer%2F))%20-%20must%20be%20invertible%0A%0A%20%20%20%20We%20start%20with%20a%20simple%20Ridge%20regressor%20and%2012%20lag%20features.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20LagTransformer%2C%0A%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20Ridge%2C%0A%20%20%20%20forecasting_horizon%2C%0A%20%20%20%20y_train%2C%0A)%3A%0A%20%20%20%20forecaster%20%3D%20PointReductionForecaster(%0A%20%20%20%20%20%20%20%20estimator%3DRidge(alpha%3D1.0)%2C%0A%20%20%20%20%20%20%20%20feature_transformer%3DLagTransformer(lag%3Dlist(range(1%2C%2013)))%2C%0A%20%20%20%20)%0A%0A%20%20%20%20forecaster.fit(y_train%2C%20forecasting_horizon%3Dforecasting_horizon)%0A%20%20%20%20print(%22Forecaster%20fitted%20successfully%22)%0A%20%20%20%20return%20(forecaster%2C)%0A%0A%0A%40app.cell%0Adef%20_(forecaster%2C%20y_test)%3A%0A%20%20%20%20y_pred%20%3D%20forecaster.predict(forecasting_horizon%3Dlen(y_test))%0A%20%20%20%20y_pred.head()%0A%20%20%20%20return%20(y_pred%2C)%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_forecast%2C%20y_pred%2C%20y_test%2C%20y_train)%3A%0A%20%20%20%20fig_basic%20%3D%20plot_forecast(%0A%20%20%20%20%20%20%20%20y_test%2C%0A%20%20%20%20%20%20%20%20y_pred%2C%0A%20%20%20%20%20%20%20%20y_train%3Dy_train%2C%0A%20%20%20%20%20%20%20%20title%3D%22Basic%20Reduction%20Forecast%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20mae%20%3D%20MeanAbsoluteError()%0A%20%20%20%20y_test_trimmed%20%3D%20y_test.head(len(y_pred))%0A%20%20%20%20mae.fit(y_train)%0A%20%20%20%20score%20%3D%20mae.score(y_test_trimmed%2C%20y_pred)%0A%20%20%20%20print(f%22MAE%3A%20%7Bscore%3A.2f%7D%22)%0A%20%20%20%20fig_basic%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.%20Feature%20Construction%20with%20%60target_as_feature%60%0A%0A%20%20%20%20The%20%60target_as_feature%60%20parameter%20controls%20what%20enters%20the%20feature%20matrix%3A%0A%0A%20%20%20%20-%20%60%22transformed%22%60%20(default)%3A%20lag%20features%20are%20built%20from%20the%20**transformed**%20target%0A%20%20%20%20-%20%60%22raw%22%60%3A%20lag%20features%20are%20built%20from%20the%20**original**%20target%20(useful%20when%20target_transformer%20changes%20the%20scale)%0A%20%20%20%20-%20%60None%60%3A%20target%20is%20**excluded**%20entirely%20-%20only%20exogenous%20X_actual%20is%20used%20as%20features%20(requires%20X_actual)%0A%0A%20%20%20%20With%20no%20%60target_transformer%60%2C%20%60%22transformed%22%60%20and%20%60%22raw%22%60%20produce%20identical%20results.%0A%20%20%20%20The%20difference%20matters%20when%20a%20target_transformer%20(like%20log%20or%20differencing)%20changes%20the%20scale.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20LagTransformer%2C%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20Ridge%2C%0A%20%20%20%20forecasting_horizon%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20y_test%2C%0A%20%20%20%20y_train%2C%0A)%3A%0A%20%20%20%20taf_scores%20%3D%20%7B%7D%0A%20%20%20%20for%20_taf%20in%20%5B%22transformed%22%2C%20%22raw%22%5D%3A%0A%20%20%20%20%20%20%20%20_fc%20%3D%20PointReductionForecaster(%0A%20%20%20%20%20%20%20%20%20%20%20%20estimator%3DRidge(alpha%3D1.0)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20target_as_feature%3D_taf%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20feature_transformer%3DLagTransformer(lag%3Dlist(range(1%2C%2013)))%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20_fc.fit(y_train%2C%20forecasting_horizon%3Dforecasting_horizon)%0A%20%20%20%20%20%20%20%20_pred%20%3D%20_fc.predict(forecasting_horizon%3Dlen(y_test))%0A%20%20%20%20%20%20%20%20_mae%20%3D%20MeanAbsoluteError()%0A%20%20%20%20%20%20%20%20_mae.fit(y_train)%0A%20%20%20%20%20%20%20%20taf_scores%5B_taf%5D%20%3D%20_mae.score(y_test.head(len(_pred))%2C%20_pred)%0A%0A%20%20%20%20mo.ui.table(%0A%20%20%20%20%20%20%20%20%5B%7B%22target_as_feature%22%3A%20k%2C%20%22MAE%22%3A%20f%22%7Bv%3A.2f%7D%22%7D%20for%20k%2C%20v%20in%20taf_scores.items()%5D%2C%0A%20%20%20%20%20%20%20%20label%3D%22MAE%20by%20target_as_feature%20(no%20target_transformer)%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.%20Adding%20Target%20Transformation%0A%0A%20%20%20%20The%20Monthly%20Tourism%20data%20has%20multiplicative%20seasonality%20(variance%20grows%20with%20level).%0A%20%20%20%20A%20%5B%60LogTransformer%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.stationarity.transformers.LogTransformer%2F)%20via%20%60target_transformer%60%20stabilizes%20variance.%20It%20is%20applied%20to%20y%0A%20%20%20%20before%20fitting%20and%20automatically%20inverted%20after%20prediction.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20LagTransformer%2C%0A%20%20%20%20LogTransformer%2C%0A%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20Ridge%2C%0A%20%20%20%20forecasting_horizon%2C%0A%20%20%20%20y_test%2C%0A%20%20%20%20y_train%2C%0A)%3A%0A%20%20%20%20forecaster_log%20%3D%20PointReductionForecaster(%0A%20%20%20%20%20%20%20%20estimator%3DRidge(alpha%3D1.0)%2C%0A%20%20%20%20%20%20%20%20target_transformer%3DLogTransformer(offset%3D1.0)%2C%0A%20%20%20%20%20%20%20%20feature_transformer%3DLagTransformer(lag%3Dlist(range(1%2C%2013)))%2C%0A%20%20%20%20)%0A%0A%20%20%20%20forecaster_log.fit(y_train%2C%20forecasting_horizon%3Dforecasting_horizon)%0A%20%20%20%20y_pred_log%20%3D%20forecaster_log.predict(forecasting_horizon%3Dlen(y_test))%0A%20%20%20%20return%20(y_pred_log%2C)%0A%0A%0A%40app.cell%0Adef%20_(MeanAbsoluteError%2C%20plot_forecast%2C%20y_pred_log%2C%20y_test%2C%20y_train)%3A%0A%20%20%20%20fig_log%20%3D%20plot_forecast(%0A%20%20%20%20%20%20%20%20y_train%3Dy_train%2C%0A%20%20%20%20%20%20%20%20y_test%3Dy_test%2C%0A%20%20%20%20%20%20%20%20y_pred%3Dy_pred_log%2C%0A%20%20%20%20%20%20%20%20title%3D%22Reduction%20Forecast%20with%20Log%20Transform%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20mae_log%20%3D%20MeanAbsoluteError()%0A%20%20%20%20y_test_log%20%3D%20y_test.head(len(y_pred_log))%0A%20%20%20%20mae_log.fit(y_train)%0A%20%20%20%20score_log%20%3D%20mae_log.score(y_test_log%2C%20y_pred_log)%0A%20%20%20%20print(f%22MAE%20with%20log%20transform%3A%20%7Bscore_log%3A.2f%7D%22)%0A%20%20%20%20fig_log%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.%20Hyperparameter%20Tuning%20with%20GridSearchCV%0A%0A%20%20%20%20We%20tune%20Ridge%20regularization%20(%60estimator__alpha%60)%2C%20lag%20count%0A%20%20%20%20(%60feature_transformer__lag%60)%2C%20and%20**%60reduction_strategy%60**%20using%0A%20%20%20%20%5B%60GridSearchCV%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.model_selection.search.GridSearchCV%2F)%20with%20time%20series%20cross-validation%20via%0A%20%20%20%20%5B%60ExpandingWindowSplitter%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.model_selection.split.ExpandingWindowSplitter%2F).%0A%0A%20%20%20%20Including%20%60reduction_strategy%60%20in%20the%20grid%20lets%20CV%20select%20the%20best%0A%20%20%20%20strategy%20automatically%20alongside%20other%20hyperparameters.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20ExpandingWindowSplitter%2C%0A%20%20%20%20GridSearchCV%2C%0A%20%20%20%20LagTransformer%2C%0A%20%20%20%20LogTransformer%2C%0A%20%20%20%20MeanAbsoluteError%2C%0A%20%20%20%20PointReductionForecaster%2C%0A%20%20%20%20Ridge%2C%0A%20%20%20%20forecasting_horizon%2C%0A%20%20%20%20y_train%2C%0A)%3A%0A%20%20%20%20forecaster_to_tune%20%3D%20PointReductionForecaster(%0A%20%20%20%20%20%20%20%20estimator%3DRidge()%2C%0A%20%20%20%20%20%20%20%20target_transformer%3DLogTransformer(offset%3D1.0)%2C%0A%20%20%20%20%20%20%20%20feature_transformer%3DLagTransformer(lag%3Dlist(range(1%2C%2013)))%2C%0A%20%20%20%20)%0A%0A%20%20%20%20param_grid%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22estimator__alpha%22%3A%20%5B0.1%2C%201.0%2C%2010.0%5D%2C%0A%20%20%20%20%20%20%20%20%22feature_transformer__lag%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20list(range(1%2C%207))%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20list(range(1%2C%2013))%2C%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22reduction_strategy%22%3A%20%5B%22multi-output%22%2C%20%22direct%22%5D%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20cv_splitter%20%3D%20ExpandingWindowSplitter(n_splits%3D2%2C%20test_size%3D24)%0A%0A%20%20%20%20grid_search%20%3D%20GridSearchCV(%0A%20%20%20%20%20%20%20%20forecaster%3Dforecaster_to_tune%2C%0A%20%20%20%20%20%20%20%20cv%3Dcv_splitter%2C%0A%20%20%20%20%20%20%20%20param_grid%3Dparam_grid%2C%0A%20%20%20%20%20%20%20%20scoring%3DMeanAbsoluteError()%2C%0A%20%20%20%20)%0A%0A%20%20%20%20grid_search.fit(y_train%2C%20forecasting_horizon%3Dforecasting_horizon)%0A%20%20%20%20print(f%22Best%20parameters%3A%20%7Bgrid_search.best_params_%7D%22)%0A%20%20%20%20print(f%22Best%20CV%20score%20(MAE)%3A%20%7B-grid_search.best_score_%3A.2f%7D%22)%0A%20%20%20%20return%20(grid_search%2C)%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%5B%60plot_cv_results_scatter%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.model_selection.plot_cv_results_scatter%2F)%20shows%20how%20the%20cross-validation%20score%20varies%0A%20%20%20%20with%20the%20%60alpha%60%20hyperparameter.%20Error%20bars%20represent%20fold-level%20variation.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(grid_search%2C%20plot_cv_results_scatter)%3A%0A%20%20%20%20plot_cv_results_scatter(%0A%20%20%20%20%20%20%20%20grid_search.cv_results_%2C%0A%20%20%20%20%20%20%20%20param_name%3D%22estimator__alpha%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Grid%20Search%20Results%3A%20Alpha%20vs%20CV%20Score%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%5B%60plot_forecast%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.plotting.forecasting.plot_forecast%2F)%20shows%20the%20best%20model's%20predictions%20against%20the%20test%20data.%0A%20%20%20%20The%20best%20hyperparameters%20were%20selected%20automatically%20by%20%5B%60GridSearchCV%60%5D(%2Fpages%2Fapi%2Fgenerated%2Fyohou.model_selection.search.GridSearchCV%2F).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(grid_search%2C%20plot_forecast%2C%20y_test%2C%20y_train)%3A%0A%20%20%20%20y_pred_tuned%20%3D%20grid_search.predict(forecasting_horizon%3Dlen(y_test))%0A%0A%20%20%20%20plot_forecast(%0A%20%20%20%20%20%20%20%20y_train%3Dy_train%2C%0A%20%20%20%20%20%20%20%20y_test%3Dy_test%2C%0A%20%20%20%20%20%20%20%20y_pred%3Dy_pred_tuned%2C%0A%20%20%20%20%20%20%20%20title%3D%22Tuned%20Reduction%20Forecast%20(GridSearchCV)%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**Strategy%20deep-dive**%3A%20See%20%5B%60reduction_strategies.py%60%5D(%2Fexamples%2Fgetting-started%2Freduction_strategies%2F)%20to%20compare%20multi-output%2C%20direct%2C%20and%20dir-rec%0A%20%20%20%20-%20**Time%20weighting**%3A%20See%20%5B%60time_weighted_reduction.py%60%5D(%2Fexamples%2Fforecasting-models%2Ftime_weighted_reduction%2F)%20for%20sample%20weight%20alignment%20strategies%0A%20%20%20%20-%20**Naive%20baselines**%3A%20See%20%5B%60naive_forecasters.py%60%5D(%2Fexamples%2Fgetting-started%2Fnaive_forecasters%2F)%20to%20compare%20with%20simple%20benchmarks%0A%20%20%20%20-%20**Multi-column%20forecasting**%3A%20See%20%5B%60multi_column_forecasting.py%60%5D(%2Fexamples%2Fpanel-data%2Fmulti_column_forecasting%2F)%20for%20multivariate%20data%0A%20%20%20%20-%20**Interval%20prediction**%3A%20See%20%5BInterval%5D(%2Fexamples%2F%23interval-forecasting)%20examples%20for%20uncertainty%20quantification%0A%20%20%20%20-%20**Decomposition**%3A%20See%20%5BStationarity%5D(%2Fexamples%2F%23stationarity)%20for%20trend%2Fseasonality%20extraction%20before%20forecasting%0A%20%20%20%20-%20**Classification**%3A%20See%20%5B%60class_proba_forecaster.py%60%5D(%2Fexamples%2Fpoint%2Fclass_proba_forecaster%2F)%20for%20categorical%20forecasting%20via%20reduction%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
b6c02c5249435ccb74f14db9a156d1ef