I am new to scikit-learn
, but it did what I was hoping for. Now, maddeningly, the only remaining issue is that I don\'t find how I could print (or even better, writ
I think you might be looking for estimated parameters of the "best" model rather than the hyper-parameters determined through grid-search. You can plug the best hyper-parameters from grid-search ('alpha' and 'l1_ratio' in your case) back to the model ('SGDClassifier' in your case) to train again. You can then find the parameters from the fitted model object.
The code could be something like this:
model2 = SGDClassifier(penalty='elasticnet',n_iter = np.ceil(10**6 / n),shuffle=True, alpha = gs.best_params_['alpha'], l1_ratio=gs.best_params_['l1_ratio'])
print(model2.coef_)
The SGDClassifier
instance fitted with the best hyperparameters is stored in gs.best_estimator_
. The coef_
and intercept_
are the fitted parameters of that best model.