bayesian-optimization 1.4.2__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. bayesian_optimization-1.5.0/PKG-INFO +343 -0
  2. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/README.md +64 -72
  3. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/bayes_opt/__init__.py +7 -0
  4. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/bayes_opt/bayesian_optimization.py +92 -30
  5. bayesian_optimization-1.5.0/bayes_opt/constraint.py +225 -0
  6. bayesian_optimization-1.5.0/bayes_opt/domain_reduction.py +271 -0
  7. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/bayes_opt/event.py +7 -0
  8. bayesian_optimization-1.5.0/bayes_opt/logger.py +298 -0
  9. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/bayes_opt/observer.py +19 -8
  10. bayesian_optimization-1.5.0/bayes_opt/target_space.py +501 -0
  11. bayesian_optimization-1.5.0/bayes_opt/util.py +415 -0
  12. bayesian_optimization-1.5.0/pyproject.toml +38 -0
  13. bayesian-optimization-1.4.2/PKG-INFO +0 -12
  14. bayesian-optimization-1.4.2/bayes_opt/constraint.py +0 -150
  15. bayesian-optimization-1.4.2/bayes_opt/domain_reduction.py +0 -129
  16. bayesian-optimization-1.4.2/bayes_opt/logger.py +0 -163
  17. bayesian-optimization-1.4.2/bayes_opt/target_space.py +0 -346
  18. bayesian-optimization-1.4.2/bayes_opt/util.py +0 -301
  19. bayesian-optimization-1.4.2/bayesian_optimization.egg-info/PKG-INFO +0 -12
  20. bayesian-optimization-1.4.2/bayesian_optimization.egg-info/SOURCES.txt +0 -17
  21. bayesian-optimization-1.4.2/bayesian_optimization.egg-info/dependency_links.txt +0 -1
  22. bayesian-optimization-1.4.2/bayesian_optimization.egg-info/requires.txt +0 -4
  23. bayesian-optimization-1.4.2/bayesian_optimization.egg-info/top_level.txt +0 -1
  24. bayesian-optimization-1.4.2/setup.cfg +0 -4
  25. bayesian-optimization-1.4.2/setup.py +0 -23
  26. {bayesian-optimization-1.4.2 → bayesian_optimization-1.5.0}/LICENSE +0 -0
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.1
2
+ Name: bayesian-optimization
3
+ Version: 1.5.0
4
+ Summary: Bayesian Optimization package
5
+ License: MIT
6
+ Author: Fernando Nogueira
7
+ Requires-Python: >=3.9,<4.0
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Dist: colorama (>=0.4.6,<0.5.0)
15
+ Requires-Dist: numpy (>=1.9.0,<2.0.0)
16
+ Requires-Dist: scikit-learn (>=1.0.0,<2.0.0)
17
+ Requires-Dist: scipy (>=1.0.0,<2.0.0)
18
+ Description-Content-Type: text/markdown
19
+
20
+ <div align="center">
21
+ <img src="https://raw.githubusercontent.com/bayesian-optimization/BayesianOptimization/master/static/func.png"><br><br>
22
+ </div>
23
+
24
+ # Bayesian Optimization
25
+
26
+ ![tests](https://github.com/bayesian-optimization/BayesianOptimization/actions/workflows/run_tests.yml/badge.svg)
27
+ [![Codecov](https://codecov.io/github/bayesian-optimization/BayesianOptimization/badge.svg?branch=master&service=github)](https://codecov.io/github/bayesian-optimization/BayesianOptimization?branch=master)
28
+ [![Pypi](https://img.shields.io/pypi/v/bayesian-optimization.svg)](https://pypi.python.org/pypi/bayesian-optimization)
29
+
30
+ Pure Python implementation of bayesian global optimization with gaussian
31
+ processes.
32
+
33
+ ## Installation
34
+
35
+ * PyPI (pip):
36
+
37
+ ```console
38
+ $ pip install bayesian-optimization
39
+ ```
40
+
41
+ * Conda from conda-forge channel:
42
+
43
+ ```console
44
+ $ conda install -c conda-forge bayesian-optimization
45
+ ```
46
+
47
+ This is a constrained global optimization package built upon bayesian inference
48
+ and gaussian process, that attempts to find the maximum value of an unknown
49
+ function in as few iterations as possible. This technique is particularly
50
+ suited for optimization of high cost functions, situations where the balance
51
+ between exploration and exploitation is important.
52
+
53
+ ## Quick Start
54
+ See below for a quick tour over the basics of the Bayesian Optimization package. More detailed information, other advanced features, and tips on usage/implementation can be found in the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) folder. I suggest that you:
55
+ - Follow the [basic tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) to learn how to use the package's most important features.
56
+ - Take a look at the [advanced tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html) to learn how to make the package more flexible, how to deal with categorical parameters, how to use observers, and more.
57
+ - Check out this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/visualization.html) with a step by step visualization of how this method works.
58
+ - To understand how to use bayesian optimization when additional constraints are present, see the [constrained optimization notebook](http://bayesian-optimization.github.io/BayesianOptimization/constraints.html).
59
+ - Explore this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/exploitation_vs_exploration.html)
60
+ exemplifying the balance between exploration and exploitation and how to
61
+ control it.
62
+ - Go over this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/sklearn_example.py)
63
+ for examples of how to tune parameters of Machine Learning models using cross validation and bayesian optimization.
64
+ - Explore the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html) to learn more about how search can be sped up by dynamically changing parameters' bounds.
65
+ - Finally, take a look at this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/async_optimization.py)
66
+ for ideas on how to implement bayesian optimization in a distributed fashion using this package.
67
+
68
+
69
+ ## How does it work?
70
+
71
+ Bayesian optimization works by constructing a posterior distribution of functions (gaussian process) that best describes the function you want to optimize. As the number of observations grows, the posterior distribution improves, and the algorithm becomes more certain of which regions in parameter space are worth exploring and which are not, as seen in the picture below.
72
+
73
+ ![BayesianOptimization in action](./static/bo_example.png)
74
+
75
+ As you iterate over and over, the algorithm balances its needs of exploration and exploitation taking into account what it knows about the target function. At each step a Gaussian Process is fitted to the known samples (points previously explored), and the posterior distribution, combined with a exploration strategy (such as UCB (Upper Confidence Bound), or EI (Expected Improvement)), are used to determine the next point that should be explored (see the gif below).
76
+
77
+ ![BayesianOptimization in action](./static/bayesian_optimization.gif)
78
+
79
+ This process is designed to minimize the number of steps required to find a combination of parameters that are close to the optimal combination. To do so, this method uses a proxy optimization problem (finding the maximum of the acquisition function) that, albeit still a hard problem, is cheaper (in the computational sense) and common tools can be employed. Therefore Bayesian Optimization is most adequate for situations where sampling the function to be optimized is a very expensive endeavor. See the references for a proper discussion of this method.
80
+
81
+ This project is under active development, if you find a bug, or anything that
82
+ needs correction, please let me know.
83
+
84
+
85
+ ## Basic tour of the Bayesian Optimization package
86
+
87
+ ### 1. Specifying the function to be optimized
88
+
89
+ This is a function optimization package, therefore the first and most important ingredient is, of course, the function to be optimized.
90
+
91
+ **DISCLAIMER:** We know exactly how the output of the function below depends on its parameter. Obviously this is just an example, and you shouldn't expect to know it in a real scenario. However, it should be clear that you don't need to. All you need in order to use this package (and more generally, this technique) is a function `f` that takes a known set of parameters and outputs a real number.
92
+
93
+
94
+ ```python
95
+ def black_box_function(x, y):
96
+ """Function with unknown internals we wish to maximize.
97
+
98
+ This is just serving as an example, for all intents and
99
+ purposes think of the internals of this function, i.e.: the process
100
+ which generates its output values, as unknown.
101
+ """
102
+ return -x ** 2 - (y - 1) ** 2 + 1
103
+ ```
104
+
105
+ ### 2. Getting Started
106
+
107
+ All we need to get started is to instantiate a `BayesianOptimization` object specifying a function to be optimized `f`, and its parameters with their corresponding bounds, `pbounds`. This is a constrained optimization technique, so you must specify the minimum and maximum values that can be probed for each parameter in order for it to work
108
+
109
+
110
+ ```python
111
+ from bayes_opt import BayesianOptimization
112
+
113
+ # Bounded region of parameter space
114
+ pbounds = {'x': (2, 4), 'y': (-3, 3)}
115
+
116
+ optimizer = BayesianOptimization(
117
+ f=black_box_function,
118
+ pbounds=pbounds,
119
+ random_state=1,
120
+ )
121
+ ```
122
+
123
+ The BayesianOptimization object will work out of the box without much tuning needed. The main method you should be aware of is `maximize`, which does exactly what you think it does.
124
+
125
+ There are many parameters you can pass to maximize, nonetheless, the most important ones are:
126
+ - `n_iter`: How many steps of bayesian optimization you want to perform. The more steps the more likely to find a good maximum you are.
127
+ - `init_points`: How many steps of **random** exploration you want to perform. Random exploration can help by diversifying the exploration space.
128
+
129
+
130
+ ```python
131
+ optimizer.maximize(
132
+ init_points=2,
133
+ n_iter=3,
134
+ )
135
+ ```
136
+
137
+ | iter | target | x | y |
138
+ -------------------------------------------------
139
+ | 1 | -7.135 | 2.834 | 1.322 |
140
+ | 2 | -7.78 | 2.0 | -1.186 |
141
+ | 3 | -19.0 | 4.0 | 3.0 |
142
+ | 4 | -16.3 | 2.378 | -2.413 |
143
+ | 5 | -4.441 | 2.105 | -0.005822 |
144
+ =================================================
145
+
146
+
147
+ The best combination of parameters and target value found can be accessed via the property `optimizer.max`.
148
+
149
+
150
+ ```python
151
+ print(optimizer.max)
152
+ >>> {'target': -4.441293113411222, 'params': {'y': -0.005822117636089974, 'x': 2.104665051994087}}
153
+ ```
154
+
155
+
156
+ While the list of all parameters probed and their corresponding target values is available via the property `optimizer.res`.
157
+
158
+
159
+ ```python
160
+ for i, res in enumerate(optimizer.res):
161
+ print("Iteration {}: \n\t{}".format(i, res))
162
+
163
+ >>> Iteration 0:
164
+ >>> {'target': -7.135455292718879, 'params': {'y': 1.3219469606529488, 'x': 2.8340440094051482}}
165
+ >>> Iteration 1:
166
+ >>> {'target': -7.779531005607566, 'params': {'y': -1.1860045642089614, 'x': 2.0002287496346898}}
167
+ >>> Iteration 2:
168
+ >>> {'target': -19.0, 'params': {'y': 3.0, 'x': 4.0}}
169
+ >>> Iteration 3:
170
+ >>> {'target': -16.29839645063864, 'params': {'y': -2.412527795983739, 'x': 2.3776144540856503}}
171
+ >>> Iteration 4:
172
+ >>> {'target': -4.441293113411222, 'params': {'y': -0.005822117636089974, 'x': 2.104665051994087}}
173
+ ```
174
+
175
+
176
+ #### 2.1 Changing bounds
177
+
178
+ During the optimization process you may realize the bounds chosen for some parameters are not adequate. For these situations you can invoke the method `set_bounds` to alter them. You can pass any combination of **existing** parameters and their associated new bounds.
179
+
180
+
181
+ ```python
182
+ optimizer.set_bounds(new_bounds={"x": (-2, 3)})
183
+
184
+ optimizer.maximize(
185
+ init_points=0,
186
+ n_iter=5,
187
+ )
188
+ ```
189
+
190
+ | iter | target | x | y |
191
+ -------------------------------------------------
192
+ | 6 | -5.145 | 2.115 | -0.2924 |
193
+ | 7 | -5.379 | 2.337 | 0.04124 |
194
+ | 8 | -3.581 | 1.874 | -0.03428 |
195
+ | 9 | -2.624 | 1.702 | 0.1472 |
196
+ | 10 | -1.762 | 1.442 | 0.1735 |
197
+ =================================================
198
+
199
+ #### 2.2 Sequential Domain Reduction
200
+
201
+ Sometimes the initial boundaries specified for a problem are too wide, and adding points to improve the response surface in regions of the solution domain is extraneous. Other times the cost function is very expensive to compute, and minimizing the number of calls is extremely beneficial.
202
+
203
+ When it's worthwhile to converge on an optimal point quickly rather than try to find the optimal point, contracting the domain around the current optimal value as the search progresses can speed up the search progress considerably. Using the `SequentialDomainReductionTransformer` the bounds of the problem can be panned and zoomed dynamically in an attempt to improve convergence.
204
+
205
+ ![sequential domain reduction](./static/sdr.png)
206
+
207
+ An example of using the `SequentialDomainReductionTransformer` is shown in the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html). More information about this method can be found in the paper ["On the robustness of a simple domain reduction scheme for simulation‐based optimization"](http://www.truegrid.com/srsm_revised.pdf).
208
+
209
+ ### 3. Guiding the optimization
210
+
211
+ It is often the case that we have an idea of regions of the parameter space where the maximum of our function might lie. For these situations the `BayesianOptimization` object allows the user to specify points to be probed. By default these will be explored lazily (`lazy=True`), meaning these points will be evaluated only the next time you call `maximize`. This probing process happens before the gaussian process takes over.
212
+
213
+ Parameters can be passed as dictionaries or as an iterable.
214
+
215
+ ```python
216
+ optimizer.probe(
217
+ params={"x": 0.5, "y": 0.7},
218
+ lazy=True,
219
+ )
220
+
221
+ optimizer.probe(
222
+ params=[-0.3, 0.1],
223
+ lazy=True,
224
+ )
225
+
226
+ # Will probe only the two points specified above
227
+ optimizer.maximize(init_points=0, n_iter=0)
228
+ ```
229
+
230
+ | iter | target | x | y |
231
+ -------------------------------------------------
232
+ | 11 | 0.66 | 0.5 | 0.7 |
233
+ | 12 | 0.1 | -0.3 | 0.1 |
234
+ =================================================
235
+
236
+
237
+ ### 4. Saving, loading and restarting
238
+
239
+ By default you can follow the progress of your optimization by setting `verbose>0` when instantiating the `BayesianOptimization` object. If you need more control over logging/alerting you will need to use an observer. For more information about observers checkout the advanced tour notebook. Here we will only see how to use the native `JSONLogger` object to save to and load progress from files.
240
+
241
+ #### 4.1 Saving progress
242
+
243
+
244
+ ```python
245
+ from bayes_opt.logger import JSONLogger
246
+ from bayes_opt.event import Events
247
+ ```
248
+
249
+ The observer paradigm works by:
250
+ 1. Instantiating an observer object.
251
+ 2. Tying the observer object to a particular event fired by an optimizer.
252
+
253
+ The `BayesianOptimization` object fires a number of internal events during optimization, in particular, everytime it probes the function and obtains a new parameter-target combination it will fire an `Events.OPTIMIZATION_STEP` event, which our logger will listen to.
254
+
255
+ **Caveat:** The logger will not look back at previously probed points.
256
+
257
+
258
+ ```python
259
+ logger = JSONLogger(path="./logs.log")
260
+ optimizer.subscribe(Events.OPTIMIZATION_STEP, logger)
261
+
262
+ # Results will be saved in ./logs.log
263
+ optimizer.maximize(
264
+ init_points=2,
265
+ n_iter=3,
266
+ )
267
+ ```
268
+
269
+ By default the previous data in the json file is removed. If you want to keep working with the same logger, the `reset` parameter in `JSONLogger` should be set to False.
270
+
271
+ #### 4.2 Loading progress
272
+
273
+ Naturally, if you stored progress you will be able to load that onto a new instance of `BayesianOptimization`. The easiest way to do it is by invoking the `load_logs` function, from the `util` submodule.
274
+
275
+
276
+ ```python
277
+ from bayes_opt.util import load_logs
278
+
279
+
280
+ new_optimizer = BayesianOptimization(
281
+ f=black_box_function,
282
+ pbounds={"x": (-2, 2), "y": (-2, 2)},
283
+ verbose=2,
284
+ random_state=7,
285
+ )
286
+
287
+ # New optimizer is loaded with previously seen points
288
+ load_logs(new_optimizer, logs=["./logs.log"]);
289
+ ```
290
+
291
+ ## Next Steps
292
+
293
+ This introduction covered the most basic functionality of the package. Checkout the [basic-tour](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) and [advanced-tour](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html), where you will find detailed explanations and other more advanced functionality. Also, browse the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) for implementation tips and ideas.
294
+
295
+ ## Minutiae
296
+
297
+ ### Citation
298
+
299
+ If you used this package in your research, please cite it:
300
+
301
+ ```
302
+ @Misc{,
303
+ author = {Fernando Nogueira},
304
+ title = {{Bayesian Optimization}: Open source constrained global optimization tool for {Python}},
305
+ year = {2014--},
306
+ url = " https://github.com/bayesian-optimization/BayesianOptimization"
307
+ }
308
+ ```
309
+ If you used any of the advanced functionalities, please additionally cite the corresponding publication:
310
+
311
+ For the `SequentialDomainTransformer`:
312
+ ```
313
+ @article{
314
+ author = {Stander, Nielen and Craig, Kenneth},
315
+ year = {2002},
316
+ month = {06},
317
+ pages = {},
318
+ title = {On the robustness of a simple domain reduction scheme for simulation-based optimization},
319
+ volume = {19},
320
+ journal = {International Journal for Computer-Aided Engineering and Software (Eng. Comput.)},
321
+ doi = {10.1108/02644400210430190}
322
+ }
323
+ ```
324
+
325
+ For constrained optimization:
326
+ ```
327
+ @inproceedings{gardner2014bayesian,
328
+ title={Bayesian optimization with inequality constraints.},
329
+ author={Gardner, Jacob R and Kusner, Matt J and Xu, Zhixiang Eddie and Weinberger, Kilian Q and Cunningham, John P},
330
+ booktitle={ICML},
331
+ volume={2014},
332
+ pages={937--945},
333
+ year={2014}
334
+ }
335
+ ```
336
+
337
+ ### References:
338
+ * http://papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf
339
+ * http://arxiv.org/pdf/1012.2599v1.pdf
340
+ * http://www.gaussianprocess.org/gpml/
341
+ * https://www.youtube.com/watch?v=vz3D36VXefI&index=10&list=PLE6Wd9FR--EdyJ5lbFl8UuGjecvVw66F6
342
+
343
+
@@ -1,16 +1,18 @@
1
1
  <div align="center">
2
- <img src="https://github.com/fmfn/BayesianOptimization/blob/master/examples/func.png"><br><br>
2
+ <img src="https://raw.githubusercontent.com/bayesian-optimization/BayesianOptimization/master/static/func.png"><br><br>
3
3
  </div>
4
4
 
5
5
  # Bayesian Optimization
6
6
 
7
- ![tests](https://github.com/fmfn/BayesianOptimization/actions/workflows/run_tests.yml/badge.svg)
8
- [![Codecov](https://codecov.io/github/fmfn/BayesianOptimization/badge.svg?branch=master&service=github)](https://codecov.io/github/fmfn/BayesianOptimization?branch=master)
7
+ ![tests](https://github.com/bayesian-optimization/BayesianOptimization/actions/workflows/run_tests.yml/badge.svg)
8
+ [![Codecov](https://codecov.io/github/bayesian-optimization/BayesianOptimization/badge.svg?branch=master&service=github)](https://codecov.io/github/bayesian-optimization/BayesianOptimization?branch=master)
9
9
  [![Pypi](https://img.shields.io/pypi/v/bayesian-optimization.svg)](https://pypi.python.org/pypi/bayesian-optimization)
10
10
 
11
11
  Pure Python implementation of bayesian global optimization with gaussian
12
12
  processes.
13
13
 
14
+ ## Installation
15
+
14
16
  * PyPI (pip):
15
17
 
16
18
  ```console
@@ -30,25 +32,18 @@ suited for optimization of high cost functions, situations where the balance
30
32
  between exploration and exploitation is important.
31
33
 
32
34
  ## Quick Start
33
- See below for a quick tour over the basics of the Bayesian Optimization package. More detailed information, other advanced features, and tips on usage/implementation can be found in the [examples](https://github.com/fmfn/BayesianOptimization/tree/master/examples) folder. I suggest that you:
34
- - Follow the
35
- [basic tour notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/basic-tour.ipynb)
36
- to learn how to use the package's most important features.
37
- - Take a look at the
38
- [advanced tour notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/advanced-tour.ipynb)
39
- to learn how to make the package more flexible, how to deal with categorical parameters, how to use observers, and more.
40
- - Check out this
41
- [notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/visualization.ipynb)
42
- with a step by step visualization of how this method works.
43
- - To understand how to use bayesian optimization when additional constraints are present, see the
44
- [constrained optimization notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/constraints.ipynb).
45
- - Explore this [notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/exploitation_vs_exploration.ipynb)
35
+ See below for a quick tour over the basics of the Bayesian Optimization package. More detailed information, other advanced features, and tips on usage/implementation can be found in the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) folder. I suggest that you:
36
+ - Follow the [basic tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) to learn how to use the package's most important features.
37
+ - Take a look at the [advanced tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html) to learn how to make the package more flexible, how to deal with categorical parameters, how to use observers, and more.
38
+ - Check out this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/visualization.html) with a step by step visualization of how this method works.
39
+ - To understand how to use bayesian optimization when additional constraints are present, see the [constrained optimization notebook](http://bayesian-optimization.github.io/BayesianOptimization/constraints.html).
40
+ - Explore this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/exploitation_vs_exploration.html)
46
41
  exemplifying the balance between exploration and exploitation and how to
47
42
  control it.
48
- - Go over this [script](https://github.com/fmfn/BayesianOptimization/blob/master/examples/sklearn_example.py)
43
+ - Go over this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/sklearn_example.py)
49
44
  for examples of how to tune parameters of Machine Learning models using cross validation and bayesian optimization.
50
- - Explore the [domain reduction notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/domain_reduction.ipynb) to learn more about how search can be sped up by dynamically changing parameters' bounds.
51
- - Finally, take a look at this [script](https://github.com/fmfn/BayesianOptimization/blob/master/examples/async_optimization.py)
45
+ - Explore the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html) to learn more about how search can be sped up by dynamically changing parameters' bounds.
46
+ - Finally, take a look at this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/async_optimization.py)
52
47
  for ideas on how to implement bayesian optimization in a distributed fashion using this package.
53
48
 
54
49
 
@@ -56,11 +51,11 @@ for ideas on how to implement bayesian optimization in a distributed fashion usi
56
51
 
57
52
  Bayesian optimization works by constructing a posterior distribution of functions (gaussian process) that best describes the function you want to optimize. As the number of observations grows, the posterior distribution improves, and the algorithm becomes more certain of which regions in parameter space are worth exploring and which are not, as seen in the picture below.
58
53
 
59
- ![BayesianOptimization in action](./examples/bo_example.png)
54
+ ![BayesianOptimization in action](./static/bo_example.png)
60
55
 
61
56
  As you iterate over and over, the algorithm balances its needs of exploration and exploitation taking into account what it knows about the target function. At each step a Gaussian Process is fitted to the known samples (points previously explored), and the posterior distribution, combined with a exploration strategy (such as UCB (Upper Confidence Bound), or EI (Expected Improvement)), are used to determine the next point that should be explored (see the gif below).
62
57
 
63
- ![BayesianOptimization in action](./examples/bayesian_optimization.gif)
58
+ ![BayesianOptimization in action](./static/bayesian_optimization.gif)
64
59
 
65
60
  This process is designed to minimize the number of steps required to find a combination of parameters that are close to the optimal combination. To do so, this method uses a proxy optimization problem (finding the maximum of the acquisition function) that, albeit still a hard problem, is cheaper (in the computational sense) and common tools can be employed. Therefore Bayesian Optimization is most adequate for situations where sampling the function to be optimized is a very expensive endeavor. See the references for a proper discussion of this method.
66
61
 
@@ -68,10 +63,9 @@ This project is under active development, if you find a bug, or anything that
68
63
  needs correction, please let me know.
69
64
 
70
65
 
71
- Basic tour of the Bayesian Optimization package
72
- ===============================================
66
+ ## Basic tour of the Bayesian Optimization package
73
67
 
74
- ## 1. Specifying the function to be optimized
68
+ ### 1. Specifying the function to be optimized
75
69
 
76
70
  This is a function optimization package, therefore the first and most important ingredient is, of course, the function to be optimized.
77
71
 
@@ -89,7 +83,7 @@ def black_box_function(x, y):
89
83
  return -x ** 2 - (y - 1) ** 2 + 1
90
84
  ```
91
85
 
92
- ## 2. Getting Started
86
+ ### 2. Getting Started
93
87
 
94
88
  All we need to get started is to instantiate a `BayesianOptimization` object specifying a function to be optimized `f`, and its parameters with their corresponding bounds, `pbounds`. This is a constrained optimization technique, so you must specify the minimum and maximum values that can be probed for each parameter in order for it to work
95
89
 
@@ -160,7 +154,7 @@ for i, res in enumerate(optimizer.res):
160
154
  ```
161
155
 
162
156
 
163
- ### 2.1 Changing bounds
157
+ #### 2.1 Changing bounds
164
158
 
165
159
  During the optimization process you may realize the bounds chosen for some parameters are not adequate. For these situations you can invoke the method `set_bounds` to alter them. You can pass any combination of **existing** parameters and their associated new bounds.
166
160
 
@@ -183,17 +177,17 @@ optimizer.maximize(
183
177
  | 10 | -1.762 | 1.442 | 0.1735 |
184
178
  =================================================
185
179
 
186
- ### 2.2 Sequential Domain Reduction
180
+ #### 2.2 Sequential Domain Reduction
187
181
 
188
182
  Sometimes the initial boundaries specified for a problem are too wide, and adding points to improve the response surface in regions of the solution domain is extraneous. Other times the cost function is very expensive to compute, and minimizing the number of calls is extremely beneficial.
189
183
 
190
184
  When it's worthwhile to converge on an optimal point quickly rather than try to find the optimal point, contracting the domain around the current optimal value as the search progresses can speed up the search progress considerably. Using the `SequentialDomainReductionTransformer` the bounds of the problem can be panned and zoomed dynamically in an attempt to improve convergence.
191
185
 
192
- ![sequential domain reduction](./examples/sdr.png)
186
+ ![sequential domain reduction](./static/sdr.png)
193
187
 
194
- An example of using the `SequentialDomainReductionTransformer` is shown in the [domain reduction notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/domain_reduction.ipynb). More information about this method can be found in the paper ["On the robustness of a simple domain reduction scheme for simulation‐based optimization"](http://www.truegrid.com/srsm_revised.pdf).
188
+ An example of using the `SequentialDomainReductionTransformer` is shown in the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html). More information about this method can be found in the paper ["On the robustness of a simple domain reduction scheme for simulation‐based optimization"](http://www.truegrid.com/srsm_revised.pdf).
195
189
 
196
- ## 3. Guiding the optimization
190
+ ### 3. Guiding the optimization
197
191
 
198
192
  It is often the case that we have an idea of regions of the parameter space where the maximum of our function might lie. For these situations the `BayesianOptimization` object allows the user to specify points to be probed. By default these will be explored lazily (`lazy=True`), meaning these points will be evaluated only the next time you call `maximize`. This probing process happens before the gaussian process takes over.
199
193
 
@@ -221,11 +215,11 @@ optimizer.maximize(init_points=0, n_iter=0)
221
215
  =================================================
222
216
 
223
217
 
224
- ## 4. Saving, loading and restarting
218
+ ### 4. Saving, loading and restarting
225
219
 
226
220
  By default you can follow the progress of your optimization by setting `verbose>0` when instantiating the `BayesianOptimization` object. If you need more control over logging/alerting you will need to use an observer. For more information about observers checkout the advanced tour notebook. Here we will only see how to use the native `JSONLogger` object to save to and load progress from files.
227
221
 
228
- ### 4.1 Saving progress
222
+ #### 4.1 Saving progress
229
223
 
230
224
 
231
225
  ```python
@@ -243,19 +237,19 @@ The `BayesianOptimization` object fires a number of internal events during optim
243
237
 
244
238
 
245
239
  ```python
246
- logger = JSONLogger(path="./logs.json")
240
+ logger = JSONLogger(path="./logs.log")
247
241
  optimizer.subscribe(Events.OPTIMIZATION_STEP, logger)
248
242
 
249
- # Results will be saved in ./logs.json
243
+ # Results will be saved in ./logs.log
250
244
  optimizer.maximize(
251
245
  init_points=2,
252
246
  n_iter=3,
253
247
  )
254
248
  ```
255
249
 
256
- By default the previous data in the json file is removed. If you want to keep working with the same logger, the `reset` paremeter in `JSONLogger` should be set to False.
250
+ By default the previous data in the json file is removed. If you want to keep working with the same logger, the `reset` parameter in `JSONLogger` should be set to False.
257
251
 
258
- ### 4.2 Loading progress
252
+ #### 4.2 Loading progress
259
253
 
260
254
  Naturally, if you stored progress you will be able to load that onto a new instance of `BayesianOptimization`. The easiest way to do it is by invoking the `load_logs` function, from the `util` submodule.
261
255
 
@@ -272,60 +266,58 @@ new_optimizer = BayesianOptimization(
272
266
  )
273
267
 
274
268
  # New optimizer is loaded with previously seen points
275
- load_logs(new_optimizer, logs=["./logs.json"]);
269
+ load_logs(new_optimizer, logs=["./logs.log"]);
276
270
  ```
277
271
 
278
272
  ## Next Steps
279
273
 
280
- This introduction covered the most basic functionality of the package. Checkout the [basic-tour](https://github.com/fmfn/BayesianOptimization/blob/master/examples/basic-tour.ipynb) and [advanced-tour](https://github.com/fmfn/BayesianOptimization/blob/master/examples/advanced-tour.ipynb) notebooks in the example folder, where you will find detailed explanations and other more advanced functionality. Also, browse the examples folder for implementation tips and ideas.
281
-
282
- Installation
283
- ============
284
-
285
- ### Installation
286
-
287
- The latest release can be obtained by two ways:
288
-
289
- * With PyPI (pip):
290
-
291
- pip install bayesian-optimization
292
-
293
- * With conda (from conda-forge channel):
294
-
295
- conda install -c conda-forge bayesian-optimization
296
-
297
- The bleeding edge version can be installed with:
298
-
299
- pip install git+https://github.com/fmfn/BayesianOptimization.git
274
+ This introduction covered the most basic functionality of the package. Checkout the [basic-tour](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) and [advanced-tour](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html), where you will find detailed explanations and other more advanced functionality. Also, browse the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) for implementation tips and ideas.
300
275
 
301
- If you prefer, you can clone it and run the setup.py file. Use the following
302
- commands to get a copy from Github and install all dependencies:
276
+ ## Minutiae
303
277
 
304
- git clone https://github.com/fmfn/BayesianOptimization.git
305
- cd BayesianOptimization
306
- python setup.py install
278
+ ### Citation
307
279
 
308
- Citation
309
- ============
310
-
311
- If you used this package in your research and is interested in citing it here's how you do it:
280
+ If you used this package in your research, please cite it:
312
281
 
313
282
  ```
314
283
  @Misc{,
315
284
  author = {Fernando Nogueira},
316
285
  title = {{Bayesian Optimization}: Open source constrained global optimization tool for {Python}},
317
286
  year = {2014--},
318
- url = " https://github.com/fmfn/BayesianOptimization"
287
+ url = " https://github.com/bayesian-optimization/BayesianOptimization"
319
288
  }
320
289
  ```
290
+ If you used any of the advanced functionalities, please additionally cite the corresponding publication:
321
291
 
322
- # Dependencies
323
- * Numpy
324
- * Scipy
325
- * Scikit-learn
292
+ For the `SequentialDomainTransformer`:
293
+ ```
294
+ @article{
295
+ author = {Stander, Nielen and Craig, Kenneth},
296
+ year = {2002},
297
+ month = {06},
298
+ pages = {},
299
+ title = {On the robustness of a simple domain reduction scheme for simulation-based optimization},
300
+ volume = {19},
301
+ journal = {International Journal for Computer-Aided Engineering and Software (Eng. Comput.)},
302
+ doi = {10.1108/02644400210430190}
303
+ }
304
+ ```
326
305
 
327
- # References:
306
+ For constrained optimization:
307
+ ```
308
+ @inproceedings{gardner2014bayesian,
309
+ title={Bayesian optimization with inequality constraints.},
310
+ author={Gardner, Jacob R and Kusner, Matt J and Xu, Zhixiang Eddie and Weinberger, Kilian Q and Cunningham, John P},
311
+ booktitle={ICML},
312
+ volume={2014},
313
+ pages={937--945},
314
+ year={2014}
315
+ }
316
+ ```
317
+
318
+ ### References:
328
319
  * http://papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf
329
320
  * http://arxiv.org/pdf/1012.2599v1.pdf
330
321
  * http://www.gaussianprocess.org/gpml/
331
322
  * https://www.youtube.com/watch?v=vz3D36VXefI&index=10&list=PLE6Wd9FR--EdyJ5lbFl8UuGjecvVw66F6
323
+
@@ -1,8 +1,15 @@
1
+ """Pure Python implementation of bayesian global optimization with gaussian processes."""
1
2
  from .bayesian_optimization import BayesianOptimization, Events
2
3
  from .domain_reduction import SequentialDomainReductionTransformer
3
4
  from .util import UtilityFunction
4
5
  from .logger import ScreenLogger, JSONLogger
5
6
  from .constraint import ConstraintModel
7
+ from .util import UtilityFunction
8
+
9
+ import importlib.metadata
10
+ __version__ = importlib.metadata.version('bayesian-optimization')
11
+
12
+
6
13
 
7
14
  __all__ = [
8
15
  "BayesianOptimization",