Skip to main content

Boax is a Bayesian Optimization library for JAX.

Project description

Boax: A Bayesian Optimization library for JAX.

tests pypi

Overview | Installation | Getting Started | Documentation

Boax is currently in early alpha and under active development!

Overview

Boax is a composable library of core components for Bayesian Optimization that is designed for flexibility.

It comes with high-level interfaces for:

  • Experiments (boax.experiments):
    • Bayesian Optimization Setups
    • Bandit Optimization Setups
    • Search Spaces

And with low-level interfaces for:

  • Constructing acquisition functions (boax.acquisition):
    • Acquisition Functions
    • Surrogate Models
  • Constructing policy functions (boax.policies):
    • Policy Functions
    • Believes
  • Core capabilities (boax.core):
    • Common Distributions
    • Gaussian Process Models
    • Objective Functions
    • Quasi-Newton Optimizers
    • Monte-Carlo Samplers

Installation

You can install the latest released version of Boax from PyPI via:

pip install boax

or you can install the latest development version from GitHub:

pip install git+https://github.com/Lando-L/boax.git

Basic Usage

Here is a basic example of using the Boax for hyperparamter tuning. For more details check out the docs.

  1. Setting up classification task:
  from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import StandardScaler
  from sklearn.svm import SVC

  iris = load_iris()
  X = iris.data
  y = iris.target

  X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
  scaler = StandardScaler()
  X_train = scaler.fit_transform(X_train)
  X_test = scaler.transform(X_test)

  def evaluate(C, gamma):
    svc = SVC(C=C, gamma=gamma, kernel='rbf')
    svc.fit(X_train, y_train)
    return svc.score(X_test, y_test)
  1. Setting up a bayesian optimization experiment.
  from jax import config
  config.update("jax_enable_x64", True)
  from boax.experiments import optimization

  experiment = optimization(
    parameters=[
      {
        'name': 'C',
        'type': 'log_range',
        'bounds': [1, 1_000],
      },
      {
        'name': 'gamma',
        'type': 'log_range',
        'bounds': [1e-4, 1e-3],
      },
    ],
    batch_size=4,
  )
  1. Running the trial for N = 25 steps.
  step, results = None, []

  for _ in range(25):
    # Retrieve next parameterizations to evaluate
    step, parameterizations = experiment.next(step, results)

    # Evaluate parameterizations
    evaluations = [
      evaluate(**parameterization)
      for parameterization in parameterizations
    ]
    
    results = list(
        zip(parameterizations, evaluations)
    )

  # Predicted best
  experiment.best(step)

Citing Boax

To cite Boax please use the citation:

@software{boax2023github,
  author = {Lando L{\"o}per},
  title = {{B}oax: A Bayesian Optimization library for {JAX}},
  url = {https://github.com/Lando-L/boax},
  version = {0.2.0},
  year = {2023},
}

In the above bibtex entry, the version number is intended to be the latest, and the year corresponds to the project's open-source release.

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

boax-0.2.0.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boax-0.2.0-py3-none-any.whl (96.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boax-0.2.0.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-1020-azure

File hashes

Hashes for boax-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0e37891b9d69931e2e935c2809f98e82e07f5c98dade8e565975b74166d3ed3b
MD5 dd5f679f8ead269e8a879b158accac72
BLAKE2b-256 82b325d96ea4629889e5b51e65bbb5722ca9a3f9346b87281a787726138b7d24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boax-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 96.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-1020-azure

File hashes

Hashes for boax-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cea813ce53f4772f3acb7353f4ff8991d7203b0330728bf11b6ea6dfca17396e
MD5 928661133d5bf67854279b17623d1130
BLAKE2b-256 ca2d726dcf26ddf7eb824fb8320a85e27cab8db33ebd4a265c3b8e881912c828

See more details on using hashes here.

Supported by

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