SubspaceContinuous¶
- class baybe.searchspace.continuous.SubspaceContinuous[source]¶
Bases:
SerialMixin
Class for managing continuous subspaces.
Builds the subspace from parameter definitions, keeps track of search metadata, and provides access to candidate sets and different parameter views.
Public methods
__init__
(parameters[, constraints_lin_eq, ...])Method generated by attrs for class SubspaceContinuous.
empty
()Create an empty continuous subspace.
from_bounds
(bounds)Create a hyperrectangle-shaped continuous subspace with given bounds.
from_dataframe
(df[, parameters])Create a hyperrectangle-shaped continuous subspace from a dataframe.
from_dict
(dictionary)Create an object from its dictionary representation.
from_json
(string)Create an object from its JSON representation.
from_parameter
(parameter)Create a subspace from a single parameter.
from_product
(parameters[, constraints])get_parameters_by_name
(names)Return parameters with the specified names.
sample_from_full_factorial
([batch_size])Draw parameter configurations from the full factorial of the space.
sample_uniform
([batch_size])Draw uniform random parameter configurations from the continuous space.
samples_full_factorial
([n_points])Deprecated!
samples_random
([n_points])Deprecated!
to_dict
()Create an object's dictionary representation.
to_json
()Create an object's JSON representation.
Turn the subspace into a search space with no discrete part.
transform
([df, allow_missing, allow_extra, data])Public attributes and properties
The parameters of the subspace.
Linear equality constraints.
Linear inequality constraints.
Nonlinear constraints.
The minimum and maximum values of the computational representation.
The columns spanning the computational representation.
Cardinality constraints.
Get the full factorial of the continuous space.
Return whether this subspace is empty.
Return tuple of parameter names.
- __init__(parameters: Collection[Parameter], constraints_lin_eq: Sequence = NOTHING, constraints_lin_ineq: Sequence = NOTHING, constraints_nonlin: Sequence = NOTHING)¶
Method generated by attrs for class SubspaceContinuous.
For details on the parameters, see Public attributes and properties.
- classmethod from_bounds(bounds: DataFrame)[source]¶
Create a hyperrectangle-shaped continuous subspace with given bounds.
- Parameters:
bounds (
DataFrame
) – The bounds of the parameters.- Return type:
- Returns:
The constructed subspace.
- classmethod from_dataframe(df: DataFrame, parameters: Sequence[ContinuousParameter] | None = None)[source]¶
Create a hyperrectangle-shaped continuous subspace from a dataframe.
More precisely, create the smallest axis-aligned hyperrectangle-shaped continuous subspace that contains the points specified in the given dataframe.
- Parameters:
df (
DataFrame
) – The dataframe specifying the points spanning the subspace.parameters (
Optional
[Sequence
[ContinuousParameter
]]) – Optional parameter objects corresponding to the columns in the given dataframe that can be provided to explicitly control parameter attributes. If a match between column name and parameter name is found, the corresponding parameter object is used. If a column has no match in the parameter list, a newbaybe.parameters.numerical.NumericalContinuousParameter
is created with default optional arguments. For more details, seebaybe.parameters.utils.get_parameters_from_dataframe()
.
- Raises:
ValueError – If parameter types other than
baybe.parameters.numerical.NumericalContinuousParameter
are provided.- Return type:
- Returns:
The created continuous subspace.
- classmethod from_parameter(parameter: ContinuousParameter)[source]¶
Create a subspace from a single parameter.
- Parameters:
parameter (
ContinuousParameter
) – The parameter to span the subspace.- Return type:
- Returns:
The created subspace.
- classmethod from_product(parameters: Sequence[ContinuousParameter], constraints: Sequence[ContinuousConstraint] | None = None)[source]¶
See
baybe.searchspace.core.SearchSpace
.- Return type:
- get_parameters_by_name(names: Sequence[str])[source]¶
Return parameters with the specified names.
- Parameters:
- Return type:
- Returns:
The named parameters.
- sample_from_full_factorial(batch_size: int = 1)[source]¶
Draw parameter configurations from the full factorial of the space.
- Parameters:
batch_size (
int
) – The number of parameter configurations to be sampled.- Return type:
- Returns:
A dataframe containing the parameter configurations as rows with columns corresponding to the parameter names.
- Raises:
ValueError – If there are not enough points to sample from.
- sample_uniform(batch_size: int = 1)[source]¶
Draw uniform random parameter configurations from the continuous space.
- Parameters:
batch_size (
int
) – The number of parameter configurations to be sampled.- Return type:
- Returns:
A dataframe containing the parameter configurations as rows with columns corresponding to the parameter names.
- Raises:
ValueError – If the subspace contains unsupported nonlinear constraints.
- to_json()¶
Create an object’s JSON representation.
- Return type:
- Returns:
The JSON representation as a string.
- to_searchspace()[source]¶
Turn the subspace into a search space with no discrete part.
- Return type:
SearchSpace
- transform(df: DataFrame | None = None, /, *, allow_missing: bool = False, allow_extra: bool | None = None, data: DataFrame | None = None)[source]¶
See
baybe.searchspace.core.SearchSpace.transform()
.- Return type:
- property comp_rep_bounds: DataFrame¶
The minimum and maximum values of the computational representation.
- property constraints_cardinality: tuple[ContinuousCardinalityConstraint, ...]¶
Cardinality constraints.
-
constraints_lin_eq:
tuple
[ContinuousLinearEqualityConstraint
,...
]¶ Linear equality constraints.
-
constraints_lin_ineq:
tuple
[ContinuousLinearInequalityConstraint
,...
]¶ Linear inequality constraints.
-
constraints_nonlin:
tuple
[ContinuousNonlinearConstraint
,...
]¶ Nonlinear constraints.
-
parameters:
tuple
[NumericalContinuousParameter
,...
]¶ The parameters of the subspace.