For the API design proposal, see this wiki entry.
FH class into separate utility functionsForecastingGridSearchCV and update_predict(), try to factor out separate cross-validation function Due to the ThetaForecaster's dependency on SES, #198 also (re-)implements the ExpSmoothingForecaster in the new framework.
Is there a way to tune both sklearn & sktime hyperparameters at the same time, when using regressors from sklearn? If not. It could be really useful to have it.
Hi @hweiTPR, yes you can do something like this:
regressor_param_grid = {"n_estimators": [100, 200, 300]}
forecaster_param_grid = {"window_length": [10, 12, 14]}
regressor = GridSearchCV(RandomForestRegressor(), param_grid=regressor_param_grid)
forecaster = RecursiveRegressionForecaster(regressor)
cv = SlidingWindowSplitter(initial_window=100)
gscv = ForecastingGridSearchCV(forecaster, cv=cv, param_grid=forecaster_param_grid)
gscv.fit(y_train)
print(gscv.best_params_, gscv.best_forecaster_.regressor_.best_params_)
>>> {'window_length': 12} {'n_estimators': 100}
That looks great! Would be helpful to have this in the documentation!
@hweiTPR I mention it already in the forecasting tutorial below cell 27: https://github.com/alan-turing-institute/sktime/blob/master/examples/01_forecasting.ipynb but without showing the code! Would appreciate a PR if you'd like to add it! 馃檪
@mloning (switching to my personal account) I totally missed that sentence. Happy to contribute. I have another question: what can I put for "score" when using ForecastingGridSearchCV? I tried smape_loss, but it threw me an error.
This should work:
from sktime.forecasting.model_selection import ForecastingGridSearchCV
from sklearn.ensemble import RandomForestRegressor
from sktime.forecasting.compose import RecursiveRegressionForecaster
from sktime.forecasting.model_selection import SlidingWindowSplitter
from sktime.performance_metrics.forecasting import sMAPE
from sklearn.model_selection import GridSearchCV
from sktime.datasets import load_airline
y_train = load_airline()
regressor_param_grid = {"n_estimators": [100, 200, 300]}
forecaster_param_grid = {"window_length": [10, 12, 14]}
regressor = GridSearchCV(RandomForestRegressor(), param_grid=regressor_param_grid)
forecaster = RecursiveRegressionForecaster(regressor)
cv = SlidingWindowSplitter(initial_window=100)
gscv = ForecastingGridSearchCV(forecaster, cv=cv, param_grid=forecaster_param_grid, scoring=sMAPE())
gscv.fit(y_train)
print(gscv.cv_results_)
This is a deviation from scikit-learn, as we encapsulated loss functions as classes rather than functions, that makes it easier to attach additional information that's needed when running GSCV. This functionality also still needs some improvements to handle multi-step forecasting horizons.
Is any one working on an interface to fb prophet? Would be happy to look in to it otherwise!
Hi @NikeNano that would be great! It's probably best to create a separate issue for it and link it here!