Skip to main content

Minimal Bayesian Optimization Implementation with Gaussian Processes written in JAX.

Project description

Bayex: Minimal Bayesian Optimization in JAX

tests

Installation | Usage | Contributing | License

Bayex is a lightweight Bayesian optimization library designed for efficiency and flexibility, leveraging the power of JAX for high-performance numerical computations. This library aims to provide an easy-to-use interface for optimizing expensive-to-evaluate functions through Gaussian Process (GP) models and various acquisition functions. Whether you're maximizing or minimizing your objective function, Bayex offers a simple yet powerful set of tools to guide your search for optimal parameters.

Installation

Bayex can be installed using PyPI via pip:

pip install bayex

or from GitHub directly

pip install git+git://github.com/alonfnt/bayex.git

Likewise, you can clone this repository and install it locally

git clone https://github.com/alonfnt/bayex.git
cd bayex
pip install -r requirements.txt

Usage

Using Bayex is quite simple despite its low level approach:

import jax
import numpy as np
import bayex

def f(x):
    return -(1.4 - 3 * x) * np.sin(18 * x)

domain = {'x': bayex.domain.Real(0.0, 2.0)}
optimizer = bayex.Optimizer(domain=domain, maximize=True, acq='PI')

# Define some prior evaluations to initialise the GP.
params = {'x': [0.0, 0.5, 1.0]}
ys = [f(x) for x in params['x']
opt_state = optimizer.init(ys, params)

# Sample new points using Jax PRNG approach.
ori_key = jax.random.key(42)
for step in range(20):
    key = jax.random.fold_in(ori_key, step)
    new_params = optimizer.sample(key, opt_state)
    y_new = f(**new_params)
    opt_state = optimizer.fit(opt_state, y_new, new_params)

with the results being saved at opt_state.

Contributing

We welcome contributions to Bayex! Whether it's adding new features, improving documentation, or reporting issues, please feel free to make a pull request or open an issue.

License

Bayex is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bayex-0.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

bayex-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file bayex-0.2.0.tar.gz.

File metadata

  • Download URL: bayex-0.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for bayex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 33ce9e946103ef281521665d7e2c1676250fc362673590aef649be5edccde365
MD5 964a801d58e1303cc8b0971e2844e548
BLAKE2b-256 a76b6eb814ce568e00003ac8674350c4df913e12a4e334d50b08fb8ed45b3392

See more details on using hashes here.

File details

Details for the file bayex-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bayex-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for bayex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3485645bc663dfee3fc4493e46d17d173fddcd15722f3d24ed01c60a52f69802
MD5 4ab5123da08712be4c9918be22184890
BLAKE2b-256 5d193481f09548e520e00f904856c760718da413be5952edee9948da7e21fc3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page