If I interrupt sklearn grid_search.fit() before completion can I access the current .best_score_, .best_params_?

回眸只為那壹抹淺笑 提交于 2019-12-24 10:26:51

问题


If I interrupt grid_search.fit() before completion will I loose everything it's done so far? I got a little carried away with my grid search and provided an obscenely large search space. I can see scores that I'm happy with already but my stdout doesn't display which params led to those scores..

I've searched the docs: http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.GridSearchCV.html

And there is a discussion from a couple years ago about adding a feature for parrallel search here: https://sourceforge.net/p/scikit-learn/mailman/message/31036457/

But nothing definitive. My search has been working for ~48hrs, so I don't want to loose what's been discovered, but I also don't want to continue.

Thanks!


回答1:


welcome to SO!

To my understanding there isn't any intermediate variables that get returned off the grid_search function, only the resulting grid and their scores (see here for more information grid search.py).

So if you cancel it you might lose the work that's been done so far.

But a bit of advice, 48 hours is a long time (obviously this depends on the rows, columns and number of hyper parameters being tuned). You might want to start with a more broad grid search first and then refine your parameter search off that.

That will benefit you two ways:

  1. Run time might end up being much shorter (see caveats above) meaning you don't have to wait so long and risk losing results

  2. You might find that your model prediction score is only impacted by one or two hyper parameters, letting you keep the other searches more broad and focussing your efforts on the parameters that influence your prediction accuracy most.

Hopefully by the time I've written this response your grid search has completed!!



来源:https://stackoverflow.com/questions/39377052/if-i-interrupt-sklearn-grid-search-fit-before-completion-can-i-access-the-curr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!