Skip to main content

Bayesian Optimization package

Project description

Bayesian Optimization

PyPI PyPI - Python Version Loc Comments

Code Test Badge Creation Package Release codecov

GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license

An extended implementation of Bayesian Optimization.

This is a forked project based on fmfn/BayesianOptimization v1.2.0. Most of the usage and features from the original repository will be kept for a long time.

Installation

You can simply install it with pip command line from the official PyPI site.

pip install hbayes

For more information about installation, you can refer to Installation.

Documentation

The detailed documentation are hosted on https://hansbug.github.io/hbayes/main/index.html.

Only english version is provided now, the chinese documentation is still under development.

Quick Start

A painless example

from hbayes import BayesianOptimization


def black_box_function(x, y):
    """Function with unknown internals we wish to maximize.

    This is just serving as an example, for all intents and
    purposes think of the internals of this function, i.e.: the process
    which generates its output values, as unknown.
    """
    return -x ** 2 - (y - 1) ** 2 + 1


# Bounded region of parameter space
pbounds = {'x': (2, 4), 'y': (-3, 3)}

optimizer = BayesianOptimization(
    f=black_box_function,
    pbounds=pbounds,
    random_state=1,
    verbose=2,
)

optimizer.maximize(
    init_points=10,
    n_iter=25,
)

print(optimizer.max)

The output should be

|   iter    |  target   |     x     |     y     |
-------------------------------------------------
|  1        | -7.135    |  2.834    |  1.322    |
|  2        | -7.78     |  2.0      | -1.186    |
|  3        | -16.13    |  2.294    | -2.446    |
|  4        | -8.341    |  2.373    | -0.9266   |
|  5        | -7.392    |  2.794    |  0.2329   |
|  6        | -7.069    |  2.838    |  1.111    |
|  7        | -6.412    |  2.409    |  2.269    |
|  8        | -3.223    |  2.055    |  1.023    |
|  9        | -7.455    |  2.835    |  0.3521   |
|  10       | -12.11    |  2.281    | -1.811    |
|  11       | -7.0      |  2.0      |  3.0      |
|  12       | -19.0     |  4.0      |  3.0      |
|  13       | -3.383    |  2.0      |  0.3812   |
|  14       | -3.43     |  2.0      |  1.656    |
|  15       | -3.035    |  2.0      |  0.8129   |
|  16       | -17.03    |  4.0      | -0.4244   |
|  17       | -3.012    |  2.0      |  1.109    |
|  18       | -3.0      |  2.0      |  0.9813   |
|  19       | -3.0      |  2.0      |  0.9911   |
|  20       | -3.0      |  2.0      |  0.994    |
|  21       | -3.0      |  2.0      |  0.9957   |
|  22       | -3.0      |  2.0      |  0.9971   |
|  23       | -3.0      |  2.0      |  0.9994   |
|  24       | -3.0      |  2.0      |  1.004    |
|  25       | -3.0      |  2.0      |  0.978    |
|  26       | -3.001    |  2.0      |  1.024    |
|  27       | -3.001    |  2.0      |  0.9735   |
|  28       | -3.001    |  2.0      |  1.024    |
|  29       | -3.001    |  2.0      |  0.9729   |
|  30       | -3.001    |  2.0      |  1.024    |
|  31       | -3.0      |  2.0      |  1.021    |
|  32       | -3.001    |  2.0      |  0.9709   |
|  33       | -3.001    |  2.0      |  0.9749   |
|  34       | -3.001    |  2.0      |  1.023    |
|  35       | -3.001    |  2.0      |  0.9755   |
=================================================
{'target': -3.00000039014846, 'params': {'x': 2.0, 'y': 0.9993753813483197}}

For more tutorial of usages and practices, take a look at Best Practice in documentation.

Contributing

We appreciate all contributions to improve hbayes, both logic and system designs. Please refer to CONTRIBUTING.md for more guides.

License

hbayes released under the MIT license.

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

hbayes-0.0.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

hbayes-0.0.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file hbayes-0.0.1.tar.gz.

File metadata

  • Download URL: hbayes-0.0.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for hbayes-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cd874155a2f819feb9f7ac64c042c9e44fd2ad7866b978deedb3303d29553767
MD5 06468e0e6ee0bba1fe99dac74746e934
BLAKE2b-256 c7c5102d9bcb3860d9ad9f3534bb8e0b34901b68875c6e1189c18034b05983d8

See more details on using hashes here.

File details

Details for the file hbayes-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: hbayes-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for hbayes-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dd1d4043458c8534bdccafa79ab916e3534cb1b9d18de9904b209871d1617fa
MD5 004e145256a4464adc506bb1374f415a
BLAKE2b-256 3eff5f1b0aeb39e55682bdeb59a33afa81846f03781afa9639dde0be7898d980

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