3

GridSearchCV implements a fit method in which it performs n-fold cross validation to determine best parameters. After this we can directly apply the best estimator to the testing data using predict() - Following this link : - http://scikit-learn.org/stable/auto_examples/grid_search_digits.html

It says here "The model is trained on the full development set"

However we have only applied n fold cross validations here. Is the classifier somehow also training itself on the entire data? or is it just choosing the best trained estimator with best parameters amongst the n-folds when applying predict?

1 Answer 1

5

If you want to use predict, you'll need to set 'refit' to True. From the documentation:

refit : boolean
    Refit the best estimator with the entire dataset. 
    If “False”, it is impossible to make predictions using 
    this GridSearchCV instance after fitting.

It looks like it is true by default, so in the example, predict is based on the whole training set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.