1414
1515
1616class ForecastingOptCV (_DelegatedForecaster ):
17- """Tune an sktime forecaster via any optimizer in the hyperactive API.
17+ """Tune an sktime forecaster via any optimizer in the hyperactive toolbox.
18+
19+ ``ForecastingOptCV`` uses any available tuning engine from ``hyperactive``
20+ to tune a forecaster by backtesting.
21+
22+ It passes backtesting results as scores to the tuning engine,
23+ which identifies the best hyperparameters.
24+
25+ Any available tuning engine from hyperactive can be used, for example:
26+
27+ * grid search - ``from hyperactive.opt import GridSearchSk as GridSearch``,
28+ this results in the same algorithm as ``ForecastingGridSearchCV``
29+ * hill climbing - ``from hyperactive.opt import HillClimbing``
30+ * optuna parzen-tree search - ``from hyperactive.opt.optuna import TPEOptimizer``
31+
32+ Configuration of the tuning engine is as per the respective documentation.
33+
34+ Formally, ``ForecastingOptCV`` does the following:
35+
36+ In ``fit``:
37+
38+ * wraps the ``forecaster``, ``scoring``, and other parameters
39+ into a ``SktimeForecastingExperiment`` instance, which is passed to the optimizer
40+ ``optimizer`` as the ``experiment`` argument.
41+ * Optimal parameters are then obtained from ``optimizer.solve``, and set
42+ as ``best_params_`` and ``best_forecaster_`` attributes.
43+ * If ``refit=True``, ``best_forecaster_`` is fitted to the entire ``y`` and ``X``.
44+
45+ In ``predict`` and ``predict``-like methods, calls the respective method
46+ of the ``best_forecaster_`` if ``refit=True``.
1847
1948 Parameters
2049 ----------
@@ -124,7 +153,13 @@ class ForecastingOptCV(_DelegatedForecaster):
124153
125154 Example
126155 -------
127- Tuning an sktime forecaster via grid search
156+ Any available tuning engine from hyperactive can be used, for example:
157+
158+ * grid search - ``from hyperactive.opt import GridSearchSk as GridSearch``
159+ * hill climbing - ``from hyperactive.opt import HillClimbing``
160+ * optuna parzen-tree search - ``from hyperactive.opt.optuna import TPEOptimizer``
161+
162+ For illustration, we use grid search, this can be replaced by any other optimizer.
128163
129164 1. defining the tuned estimator:
130165 >>> from sktime.forecasting.naive import NaiveForecaster
@@ -151,9 +186,9 @@ class ForecastingOptCV(_DelegatedForecaster):
151186 ForecastingOptCV(...)
152187 >>> y_pred = tuned_naive.predict()
153188
154- 3. obtaining best parameters and best estimator
189+ 3. obtaining best parameters and best forecaster
155190 >>> best_params = tuned_naive.best_params_
156- >>> best_estimator = tuned_naive.best_forecaster_
191+ >>> best_forecaster = tuned_naive.best_forecaster_
157192 """
158193
159194 _tags = {
0 commit comments