unit8co/darts

[BUG] gridsearch with RegressionModel

Open

#2,104 opened on Dec 1, 2023

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Python (762 forks)batch import
buggood first issue

Repository metrics

Stars
 (6,832 stars)
PR merge metrics
 (Avg merge 143d 16h) (16 merged PRs in 30d)

Description

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?

Contributor guide