Skip to content

Optimizing over non-float Parameters #570

@amir-shahbazi23

Description

@amir-shahbazi23

Describe the bug
The package cannot handle integer variables.
I was wondering if it is because of the Python version (currently I am using Python 3.10), or the feature is deprecated.

Ex:

from bayes_opt import BayesianOptimization
def target_function_1d(x):
    return np.sin(np.round(x)) - np.abs(np.round(x) / 5)
# one way of constructing an integer-valued parameter is to add a third element to the tuple
d_pbounds = {'x': (-10, 10, int)}
bo_disc = BayesianOptimization(target_function_1d, d_pbounds, verbose=0, random_state=1)

Error:

File ".../python3.10/site-packages/bayes_opt/target_space.py", line 84, in init
self._bounds: NDArray[Float] = np.array(
TypeError: float() argument must be a string or a real number, not 'type'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions