Can somebody highlight when to use BayesianSearchCV and how it works? I have seen the implementation of same on kaggle and wanted to explore it further.

Below is the link where the implementation has been performed.

Kaggle link to Bayesian Optimization


1 Answer 1


As mentioned in that Kaggle notebook, you can use it pretty much as just a drop-in replacement for other search methods (grid or random). Bayesian searches still are random searches over a predefined search space/distribution, but now the algorithm pays attention to how well hyperparameter combinations perform, and will put more emphasis on high-performing areas.

There are several ways to do this. In BayesianSearchCV, a surrogate function keeps track of how the algorithm thinks hyperparameters will perform, with some uncertainty. Yet another function, an acquisition function, balances the desire to exploit high-performing areas with that to decrease uncertainty about unexplored areas (to avoid falling into a local optimum). A couple of nice descriptions:

SciKit-Opt is specifically tailored for optimizing very expensive functions; it spends a fair amount of time updating its surrogate and acquisition functions and choosing the next hyperparameter combination to test. By doing so, it generally requires fewer iterations to get good results, but spends longer per iteration. This is probably a good tradeoff for, say, neural networks, but less clearly for XGBoost. But if you really need to eke out the last ounce of performance, it might be worth doing Bayesian over a purely random search.

(The search begins with a number of randomly selected hyperparameter combinations, defaulting to 10 in skopt. So in that version of the Kaggle notebook, actually just a random search is being performed.)


Your Answer

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

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