optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the...
Transcript of optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the...
![Page 1: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/1.jpg)
Bayesian optimization with Scikit-Optimize
Gilles Louppe@glouppe PyData Amsterdam 2017
![Page 2: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/2.jpg)
Pause café?
You have an espresso machine with many buttons and knobs to tweak.
Your task is to brew the best cup of espresso before dying of caffeine overdose.
Credits: Steampunk coffee machine
![Page 3: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/3.jpg)
● f is a black box function, with no closed form nor gradients.
● f is expensive to evaluate.
● You may only have noisy observations of f.
![Page 4: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/4.jpg)
If you do not have these constraints, do not use Bayesian optimization.
![Page 5: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/5.jpg)
Bayesian optimisation, step-by-step
Start with observations of the objective f :
![Page 6: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/6.jpg)
Bayesian optimisation, step-by-step
Build a probabilistic model for f (typically, a Gaussian process).
![Page 7: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/7.jpg)
Bayesian optimisation, step-by-step
Optimize a cheap utility function u based on the posterior distribution for sampling the next point.
![Page 8: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/8.jpg)
Bayesian optimisation, step-by-step
Evaluate f and repeat.
![Page 9: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/9.jpg)
What is Bayesian about Bayesian optimization?
● The unknown objective is considered as a random function (a stochastic process) on which we place a prior (here defined by a Gaussian process capturing our beliefs about the function behaviour).
● Function evaluations are treated as data and used to update the prior to form the posterior distribution over the objective function.
![Page 10: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/10.jpg)
Scikit-Optimize
pip install scikit-optimize
A simple library for black-box optimization with a
scipy.optimize interface.
Sprouted from a (never-ending) Scikit-Learn pull request.
https://scikit-optimize.github.io
![Page 11: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/11.jpg)
Objective function
● Takes a list of values as argument.
● Returns a scalar (the lower, the better)
![Page 12: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/12.jpg)
Minimize
● Takes the objective function and the boundsof the parameter space.
● That’s it!
● The r tuple containsall the results (final and intermediate).
![Page 13: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/13.jpg)
Visualization
● Convergence plot● Pairwise partial dependence plot
of the surrogate objective.
![Page 14: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/14.jpg)
Acquisition function
Specifies the next sample x.
● Upper confidence bound
● Probability of improvement
● Expected improvement
provides a knob for controlling the exploration-exploitation trade-off.
Credits: arXiv:1012.2599
![Page 15: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/15.jpg)
Surrogate model
The probabilistic model for f is usually built as a Gaussian Process.
Scikit-Optimize supports any Scikit-Learn regressor that can also return the variance of the predictions (return_std=True).
● Random forests / Extra-trees ● Gradient boosting
Tree-based optimization is fast and usually better on discontinuous high-dimensional spaces.
Random forests as a probabilistic model.
![Page 16: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/16.jpg)
Is this better than random?Was this actually worth it?
![Page 17: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/17.jpg)
Random search
● If nothing works, try randomsearch.
● Works surprisingly well,often only slightly worse than“smart” algorithms.
Ouf!
![Page 18: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/18.jpg)
Wait.
That’s nice, but how do I put my coffee maker into a Python function?
Credits: 3Dprint
![Page 19: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/19.jpg)
Ask and tell API
● Factor out the evaluation of the objective function.
● ask: query next point to evaluatetell: provide function value
● Resume long optimization by pickling/unpickling the Optimizer object.
![Page 20: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/20.jpg)
Beyond coffee (or ML)
Tuning high energy physics simulators to match experimental data (e.g., 1610.08328)
Credits: ATLAS
![Page 21: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/21.jpg)
Good coffee is expensive and does not come with gradients.Bayesian optimisation can help.
![Page 22: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/22.jpg)
Summary
● Bayesian optimisation is a principled approach for optimising an expensive function f.
● Scikit-Optimize provides an easy-to-use set of tools for this.
![Page 23: optimization with Scikit-Optimize Bayesian · Resume long optimization by pickling/unpickling the Optimizer object. Beyond coffee (or ML) Tuning high energy physics simulators to](https://reader034.fdocuments.in/reader034/viewer/2022050507/5f98c9d9755add1780687979/html5/thumbnails/23.jpg)
We want you!Help us improve Scikit-Optimize
https://github.com/scikit-optimize/scikit-optimize