This is a follow-up question of https://stackoverflow.com/questions/41127976/confusing-example-of-nested-cross-validation-in-scikit-learn.

How would one retrieve the best parameters of the inner cross validation loop of the nested CV example linked in that question?. Is it exactly the question raised in this issue: https://github.com/scikit-learn/scikit-learn/issues/6827?

In other words, the best performing model should be chosen from the GridSearchCV optimized internally within cross_val_score, is that right?

[Assuming that we had only one experiment instead of the NUM_TRIALS of the example] Selecting directly clf.best_params_ (from the outer clf object) instead of inspecting the fitted GridSearchCV inside cross_val_score would be wrong, wouldn't it?

  • $\begingroup$ If this is a followup question to a StackOverflow question why isn't it being posted on StackOverflow? $\endgroup$ – Michael R. Chernick Jan 2 '17 at 14:56

You cannot access the parameters of the GridSearchCV object. For this, I advice to write the for loop of cross_val_score manually. Anyhow, you'll probably need to write some persistence code to store the results that you're interested in, so it will require for loops and custom code. Hence you should most likely expend that for loop.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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