Parameter classes for Bayesian optimization.
-
class bayes_opt.parameter.BayesParameter(name: str, bounds: ndarray[Any, dtype[Any]]) → None
Base class for Bayesian optimization parameters.
- Parameters:
- name : str
The name of the parameter.
- bounds : NDArray[Any]
-
-
property bounds : ndarray[Any, dtype[Any]]
The bounds of the parameter in float space.
-
abstract property dim : int
The dimensionality of the parameter.
-
abstract property is_continuous : bool
Whether the parameter is continuous.
-
abstract kernel_transform(value: ndarray[Any, dtype[floating[Any]]]) → ndarray[Any, dtype[floating[Any]]]
Transform a parameter value for use in a kernel.
- Parameters:
- value : np.ndarray
The value(s) to transform, should be a float.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray
-
random_sample(n_samples: int, random_state: RandomState | int | None) → ndarray[Any, dtype[floating[Any]]]
Generate random samples from the parameter.
- Parameters:
- n_samples : int
The number of samples to generate.
- random_state : np.random.RandomState | int | None
The random state to use for sampling.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray – The samples.
-
abstract to_float(value: Any) → float | ndarray[Any, dtype[floating[Any]]]
Convert a parameter value to a float.
- Parameters:
- value : Any
The value to convert, should be the canonical representation of the parameter.
- Return type:
float
| ndarray
[Any
, dtype
[floating
[Any
]]]
-
abstract to_param(value: float | ndarray[Any, dtype[floating[Any]]]) → Any
Convert a float value to a parameter.
- Parameters:
- value : np.ndarray
The value to convert, should be a float.
- Return type:
Any
- Returns:
Any – The canonical representation of the parameter.
-
to_string(value: Any, str_len: int) → str
Represent a parameter value as a string.
- Parameters:
- value : Any
The value to represent.
- str_len : int
The maximum length of the string representation.
- Return type:
str
- Returns:
str
-
class bayes_opt.parameter.CategoricalParameter(name: str, categories: Sequence[Any]) → None
A parameter with categorical values.
- Parameters:
- name : str
The name of the parameter.
- categories : Sequence[Any]
The categories of the parameter.
-
property dim : int
The dimensionality of the parameter.
-
property is_continuous : bool
Whether the parameter is continuous.
-
kernel_transform(value: ndarray[Any, dtype[floating[Any]]]) → ndarray[Any, dtype[floating[Any]]]
Transform a parameter value for use in a kernel.
- Parameters:
- value : np.ndarray
The value(s) to transform, should be a float.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray
-
random_sample(n_samples: int, random_state: RandomState | int | None) → ndarray[Any, dtype[floating[Any]]]
Generate random float-format samples from the parameter.
- Parameters:
- n_samples : int
The number of samples to generate.
- random_state : np.random.RandomState | int | None
The random state to use for sampling.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray – The samples.
-
to_float(value: Any) → ndarray[Any, dtype[floating[Any]]]
Convert a parameter value to a float.
- Parameters:
- value : Any
The value to convert, should be the canonical representation of the parameter.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
-
to_param(value: float | ndarray[Any, dtype[floating[Any]]]) → Any
Convert a float value to a parameter.
- Parameters:
- value : np.ndarray
The value to convert, should be a float.
- Return type:
Any
- Returns:
Any – The canonical representation of the parameter.
-
to_string(value: Any, str_len: int) → str
Represent a parameter value as a string.
- Parameters:
- value : Any
The value to represent.
- str_len : int
The maximum length of the string representation.
- Return type:
str
- Returns:
str
-
class bayes_opt.parameter.FloatParameter(name: str, bounds: tuple[float, float]) → None
A parameter with float values.
- Parameters:
- name : str
The name of the parameter.
- bounds : tuple[float, float]
The bounds of the parameter.
-
property dim : int
The dimensionality of the parameter.
-
property is_continuous : bool
Whether the parameter is continuous.
-
kernel_transform(value: ndarray[Any, dtype[floating[Any]]]) → ndarray[Any, dtype[floating[Any]]]
Transform a parameter value for use in a kernel.
- Parameters:
- value : np.ndarray
The value(s) to transform, should be a float.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray
-
to_float(value: float) → float
Convert a parameter value to a float.
- Parameters:
- value : Any
The value to convert, should be the canonical representation of the parameter.
- Return type:
float
-
to_param(value: float | ndarray[Any, dtype[floating[Any]]]) → float
Convert a float value to a parameter.
- Parameters:
- value : np.ndarray
The value to convert, should be a float.
- Return type:
float
- Returns:
Any – The canonical representation of the parameter.
-
to_string(value: float, str_len: int) → str
Represent a parameter value as a string.
- Parameters:
- value : Any
The value to represent.
- str_len : int
The maximum length of the string representation.
- Return type:
str
- Returns:
str
-
class bayes_opt.parameter.IntParameter(name: str, bounds: tuple[int, int]) → None
A parameter with int values.
- Parameters:
- name : str
The name of the parameter.
- bounds : tuple[int, int]
The bounds of the parameter.
-
property dim : int
The dimensionality of the parameter.
-
property is_continuous : bool
Whether the parameter is continuous.
-
kernel_transform(value: ndarray[Any, dtype[floating[Any]]]) → ndarray[Any, dtype[floating[Any]]]
Transform a parameter value for use in a kernel.
- Parameters:
- value : np.ndarray
The value(s) to transform, should be a float.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray
-
random_sample(n_samples: int, random_state: RandomState | int | None) → ndarray[Any, dtype[floating[Any]]]
Generate random samples from the parameter.
- Parameters:
- n_samples : int
The number of samples to generate.
- random_state : np.random.RandomState | int | None
The random state to use for sampling.
- Return type:
ndarray
[Any
, dtype
[floating
[Any
]]]
- Returns:
np.ndarray – The samples.
-
to_float(value: int | float) → float
Convert a parameter value to a float.
- Parameters:
- value : Any
The value to convert, should be the canonical representation of the parameter.
- Return type:
float
-
to_param(value: int | float | ndarray[Any, dtype[integer[Any]]] | ndarray[Any, dtype[floating[Any]]]) → int
Convert a float value to a parameter.
- Parameters:
- value : np.ndarray
The value to convert, should be a float.
- Return type:
int
- Returns:
Any – The canonical representation of the parameter.
-
bayes_opt.parameter.is_numeric(value: Any) → bool
Check if a value is numeric.
- Return type:
bool
- Parameters:
- value : Any
-
-
bayes_opt.parameter.wrap_kernel(kernel: Kernel, transform: Callable[[Any], Any]) → Kernel
Wrap a kernel to transform input data before passing it to the kernel.
- Parameters:
- kernel : kernels.Kernel
The kernel to wrap.
- transform : Callable
The transformation function to apply to the input data.
- Return type:
Kernel
- Returns:
kernels.Kernel – The wrapped kernel.
Notes
See https://arxiv.org/abs/1805.03463 for more information.