Exemplo n.º 1
0
"""
Example of using the scikit-optimize backend and gaussian_process algorithm with BBopt.

To run this example, just run:
    > bbopt ./skopt_example.py
"""

# BBopt setup:
from bbopt import BlackBoxOptimizer
bb = BlackBoxOptimizer(file=__file__)
if __name__ == "__main__":
    bb.run(alg="gaussian_process")


# Let's use some parameters!
x0 = bb.randrange("x0", 1, 11, guess=5)
x1 = bb.uniform("x1", 0, 1)
x2 = bb.choice("x2", [-10, -1, 0, 1, 10])


# And let's set our goal!
y = x0 + x1*x2
bb.minimize(y)


# Finally, we'll print out the value we used for debugging purposes.
if __name__ == "__main__":
    print(repr(y))
Exemplo n.º 2
0
"""
Example of using BBopt with conditional parameters and randomness
while leveraging the bayes-skopt backend.

To run this example, just run:
    > bbopt ./bask_example.py
"""

# BBopt setup:
from bbopt import BlackBoxOptimizer
bb = BlackBoxOptimizer(file=__file__)
if __name__ == "__main__":
    bb.run(alg="bask_gaussian_process")

# We set the x parameter conditional on the use_high parameter and add randomness.
import random
use_high = bb.randbool("use high", guess=False)
assert isinstance(use_high, bool), type(use_high)
if use_high:
    x = bb.randrange("x high", 10, 20) * random.random()
else:
    x = bb.randrange("x low", 10) * random.random()

# We set x as the thing we want to optimize.
bb.maximize(x)

# Finally, we'll print out the value we used for debugging purposes.
if __name__ == "__main__":
    print(repr(x))
Exemplo n.º 3
0
"""
Example of using BBopt with conditional parameters that only appear
during some runs depending on the value(s) of other parameters.

To run this example, just run:
    > bbopt ./conditional_hyperopt_example.py
"""

# BBopt setup:
from bbopt import BlackBoxOptimizer
bb = BlackBoxOptimizer(file=__file__)
if __name__ == "__main__":
    bb.run(alg="tree_structured_parzen_estimator")

# We set the x parameter conditional on the use_high parameter.
use_high = bb.randbool("use high", guess=False)
assert isinstance(use_high, bool)
if use_high:
    x = bb.randrange("x high", 10, 20)
else:
    x = bb.randrange("x low", 10)

# We set x as the thing we want to optimize.
bb.maximize(x)

# Finally, we'll print out the value we used for debugging purposes.
if __name__ == "__main__":
    print(repr(x))