Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get best_estimator parameters from GridSearch using cross_val_score?

Tags:

scikit-learn

I want to know the result of the GridSearch when I'm using nested cross validation with cross_val_score for convenience.

When using cross_val_score, you get an array of scores. It would be useful to receive the fitted estimator back or a summary of the chosen parameters for that estimator.

I know you can do this yourself but just implementing cross-validation manually but it is much more convenient if it can be done in conjunction with cross_val_score.

Any way to do it or is this a feature to suggest?

like image 548
aleph4 Avatar asked Jun 22 '13 21:06

aleph4


1 Answers

The GridSearchCV class in scikit-learn already does cross validation internally. You can pass any CV iterator as the cv argument of the constructor of GridSearchCV.

like image 139
ogrisel Avatar answered Oct 21 '22 14:10

ogrisel