Skip to main content

BORE: Bayesian Optimization as Density-Ratio Estimation

https://img.shields.io/pypi/v/bore.svg https://img.shields.io/travis/ltiao/bore.svg Documentation Status Updates

A minimalistic implementation of BORE: Bayesian Optimization as Density-Ratio Estimation [1] in Python 3 and TensorFlow 2.

featured

Getting Started

Install with pip:

$ pip install "bore[tf]"

With support for GPU accelaration:

$ pip install "bore[tf-gpu]"

With support for HpBandSter plugin:

$ pip install "bore[tf,hpbandster]"

Usage/Examples

This example implements an instantiation of BORE based on a multi-layer perceptron (i.e. a fully-connected feed-forward neural network) classifier.

First we build and compile the classifier model using MaximizableSequential:

from bore.models import MaximizableSequential
from tensorflow.keras.layers import Dense

# build model
classifier = MaximizableSequential()
classifier.add(Dense(16, activation="relu"))
classifier.add(Dense(16, activation="relu"))
classifier.add(Dense(1, activation="sigmoid"))

# compile model
classifier.compile(optimizer="adam", loss="binary_crossentropy")

This syntax should be familiar to anyone who has used a high-level neural network library such as Keras. In fact, MaximizableSequential is simply a subclass of the Sequential class from Keras. More specifically, in addition to inheriting the usual functionalities, it provides the argmax method which finds the input at which the network output is maximized.

Using this method, the standard optimization loop can be implemented as follows:

import numpy as np

features = []
targets = []

# initial design
features.extend(features_init)
targets.extend(targets_init)

for i in range(num_iterations):

    # construct classification problem
    X = np.vstack(features)
    y = np.hstack(targets)

    tau = np.quantile(y, q=0.25)
    z = np.less(y, tau)

    # update classifier
    classifier.fit(X, z, epochs=200, batch_size=64)

    # suggest new candidate
    x_next = classifier.argmax(method="L-BFGS-B", num_start_points=3, bounds=bounds)

    # evaluate blackbox function
    y_next = blackbox.evaluate(x_next)

    # update dataset
    features.append(x_next)
    targets.append(y_next)

For complete end-to-end scripts and to reproduce our results, take a look at the associated experiments repository.

Features

  • BORE-MLP: BORE based on a multi-layer perceptron (MLP) classifier

    • Provides higher-order functions that leverage automatic differentiation to transform Keras models into functions that can easily be optimized by methods in SciPy, not least multi-started quasi-Newton hill-climbing methods such as L-BFGS.

Roadmap

  • Integration with the Optuna framework by implementing a Sampler plugin.

Authors

Lead Developers:

tiao

klein

Louis Tiao

Aaron Klein

https://tiao.io/

https://aaronkl.github.io/

Reference

Cite:

@inproceedings{tiao2021-bore,
  title={{B}ayesian {O}ptimization by {D}ensity-{R}atio {E}stimation},
  author={Tiao, Louis and Klein, Aaron and Archambeau, C\'{e}dric and Bonilla, Edwin V and Seeger, Matthias and Ramos, Fabio},
  booktitle={Proceedings of the 38th International Conference on Machine Learning (ICML2021)},
  address={Virtual (Online)},
  year={2021},
  month={July}
}

License

MIT License

Copyright (c) 2021, Louis C. Tiao

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

History

0.1.0 (2019-12-27)

  • First release on PyPI.

Metadata

Release files for bore 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bore 1.5.0
File Size Uploaded
bore-1.5.0.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for bore 1.5.0
File Interpreter ABI Platform
bore-1.5.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 1.4 MB

Release files / bore-1.5.0.tar.gz

Download URL bore-1.5.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
8ffd74d2a4419774385b0b19ac9fcc9baa7d94999e29da728cb446dfcee7f485
BLAKE2b-256 checksum
How to use checksums
bdc65e0fdb1abe21f6b7f4d233ed674c1542f8f84a8da91dc276fc36e2f5c12f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release files / bore-1.5.0-py2.py3-none-any.whl

Download URL bore-1.5.0-py2.py3-none-any.whl
Size 27.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
39fbba0f0464476ceb14d5a3adf840858bd56e899fa390a9f1e9cd706c14dbd6
BLAKE2b-256 checksum
How to use checksums
d0288f2df31c85533b00f93e708aa89321734d019e7d3b245d91003a079d34f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page