BOlib
A python library for Bayesian Optimization.
Setup BOlib
-
Create and activate venv
python3 -m venv .env source .env/bin/activate
-
Upgrade pip
python -m pip install --upgrade pip
-
Install BOlib package
python -m pip install bolib
-
Matplotlib requires to install a backend to work interactively
(See https://matplotlib.org/faq/virtualenv_faq.html). The easiest solution is to install the Tk framework, which can be found as python-tk (or python3-tk) on certain Linux distributions.
Use BOlib
-
Import BOlib to use it in your python script.
import bolib
-
Some well-known objetive functions have been included.
of = bolib.ofs.Branin() of.evaluate([1.0, 1.0]) # 27.702905548512433
-
To use Bayesian Optimization we need a probabilistic model. In this example we will use Gaussian Processes.
import gplib model = gplib.GP( mean_function=gplib.mea.Fixed(), covariance_function=gplib.ker.SquaredExponential(ls=([1.] * of.d)) ) metric = gplib.me.LML() fitting_method = gplib.fit.MultiStart( obj_fun=metric.fold_measure, max_fun_call=300, nested_fit_method=gplib.fit.LocalSearch( obj_fun=metric.fold_measure, max_fun_call=75, method='Powell' ) ) validation = gplib.vm.Full()
-
Bayesian Optimization also needs an acquisition function.
af = bolib.afs.ExpectedImprovement()
-
Finally, we can initialize our optimization model and start the optimization process.
bo = bolib.methods.BayesianOptimization( model, fitting_method, validation, af ) bo.set_seed(seed=1) x0 = bo.random_sample(of.get_bounds(), batch_size=10) bo.minimize( of.evaluate, x0, bounds=of.get_bounds(), tol=1e-5, maxiter=of.get_max_eval(), disp=True )
-
BOlib is also Scipy compatible.
import scipy.optimize as spo bo.set_seed(seed=1) x0 = bo.random_sample(of.get_bounds(), batch_size=1)[0] result = spo.minimize( of.evaluate, x0, bounds=of.get_bounds(), method=bo.minimize, tol=1e-5, options={ 'maxiter': of.get_max_eval(), 'disp': True } )
-
There are more examples in examples/ directory. Check them out!
Develop BOlib
-
Update API documentation
source ./.env/bin/activate pip install Sphinx cd docs/ sphinx-apidoc -f -o ./ ../bolib
Metadata
Release files for bolib 0.22.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bolib-0.22.0.tar.gz | 32.8 kB | Without provenance | Details for bolib-0.22.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bolib-0.22.0-py3-none-any.whl | Python 3 | none | any | Details for bolib-0.22.0-py3-none-any.whl |
Total release size: 79.5 kB
Release files / bolib-0.22.0.tar.gz
| Download URL | bolib-0.22.0.tar.gz |
|---|---|
| Size | 32.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a32df64dad9840b938e37317e34c851409c8d4bd0a09b2137fc2f8415679f6ca
|
|
BLAKE2b-256 checksum How to use checksums |
b74e4d0acd95c0ed14dd2c9c6829deb8e1be31951575430ee52dae6e0f56131e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / bolib-0.22.0-py3-none-any.whl
| Download URL | bolib-0.22.0-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d15cd156168a07976d5607ffc9d967c2a1b573c664694357b0605d2c4a1fca27
|
|
BLAKE2b-256 checksum How to use checksums |
7c84566c138efd076166c710a18c16a4a943656b5be687b8ffab3a339fc5f118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for bolib 0.22.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.