I'm new to using pipelines. and I will need to use the ElasticNetCV.
I start by making a parameter grid
scaler = StandardScaler() # Transformeur : Normalisation
selector = SelectKBest() # Transformeur : Séléction de variables
enCV = ElasticNetCV() # Modèle : Support Vector Classifier
enCV_pipe = Pipeline([('scaling', scaler), # Etape 1 : Normalisation des données
('selection', selector), # Etape 2 : Sélection des k meilleures variables
('model', enCV)]) # Etape 3 : Entrainement d'un modèle SVC
param_grid = {
"selection__k" : [3, 5, 10, 20, 50, 'all'], # On teste avec 10, 20, ... , 50 et toutes les variables de X
"max_iter" : [1, 5, 10],
"alpha" : [0.0001, 0.001, 0.01, 0.1, 1, 10, 100],
"l1_ratio" : np.arange(0.0, 1.0, 0.1)
}
Then in a new cell I start my pipeline.
grid = GridSearchCV(estimator = svc_pipe, param_grid = param_grid, cv = 5, iid = True) # Instanciation d'une GridSearchCV
grid = GridSearchCV(estimator = enCV_pipe, param_grid = param_grid, cv = 2) # Instanciation d'une GridSearchCV
grid.fit(X_train,y_train) # Entraînement de la GridSearchCV pour trouver les meilleurs paramètres de la pipeline.
print(grid.best_params_) # Affichage des meilleurs paramètres pour la pipeline svc_pipe.
print(grid.best_score_) # Affichage du score obtenu par validation croisée avec les meilleurs paramètres.
and I get this error for an invalid parameter it seems. but I can't find what is wrong
ValueError: Invalid parameter alpha for estimator Pipeline(steps=[('scaling', StandardScaler()), ('selection', SelectKBest()), ('model', ElasticNetCV())]). Check the list of available parameters with
estimator.get_params().keys().
Can you give me your advice to improve my code?
Thanks in advance