unit8co / darts

A python library for user-friendly forecasting and anomaly detection on time series.
https://unit8co.github.io/darts/
Apache License 2.0
7.91k stars 857 forks source link

[BUG] gridsearch with RegressionModel #2104

Open ETTAN93 opened 9 months ago

ETTAN93 commented 9 months ago

I am trying to implement grid search for 3 parameters in the elasticnet regression model from sklearn and wrapping the darts RegressionModel around that. Based on the documentation of grid search, this is how I initialised the grid search:

grid_params = {
    'max_iter': [1, 5, 10, 50, 100, 200],
    'alpha': [1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 0.0, 1.0, 10.0, 100.0],
    'l1_ratio': [0.01, 0.1, 0.3, 0.6, 0.9, 1]
}

sklearn_elasticnet_model = make_pipeline(
    ElasticNet(random_state = 42)
)

elasticnet_model = RegressionModel(
    lags=target_lags,
    lags_past_covariates=past_cov_lags, 
    lags_future_covariates=future_cov_lags,
    output_chunk_length=forecast_horizon,
    multi_models=True,
    model=sklearn_elasticnet_model
)

elasticnet_model.gridsearch(grid_params,
                            series=target_series_sample,
                            future_covariates=future_cov_sample,
                            forecast_horizon=24,
                            stride=24)

However, I am getting this error: TypeError: RegressionModel.__init__() got an unexpected keyword argument 'max_iter'. Am I implementing it wrongly?

madtoinou commented 9 months ago

Hi @ETTAN93,

Thank you for raising this issue. gridsearch() does not support the optimization of the parameters of the wrapped model at the moment, I added it to the roadmap.