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.
samples_full_factorial
([n_points])Get random point samples from the full factorial of the continuous space.
samples_random
([n_points])Get random point samples from the continuous space.
to_dict
()Create an object's dictionary representation.
to_json
()Create an object's JSON representation.
transform
(data)See
baybe.searchspace.discrete.SubspaceDiscrete.transform()
.Public attributes and properties
The list of parameters of the subspace.
List of linear equality constraints.
List of linear inequality constraints.
Get the full factorial of the continuous space.
Return whether this subspace is empty.
Return bounds as numpy array.
Return list of parameter names.
- __init__(parameters: list[NumericalContinuousParameter], constraints_lin_eq: list[ContinuousLinearEqualityConstraint] = NOTHING, constraints_lin_ineq: list[ContinuousLinearInequalityConstraint] = 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: list[NumericalContinuousParameter] | 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
[list
[NumericalContinuousParameter
]]) – 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()
.
- Return type:
- Returns:
The created continuous subspace.
- samples_full_factorial(n_points: int = 1)[source]¶
Get random point samples from the full factorial of the continuous space.
- Parameters:
n_points (
int
) – Number of points that should be sampled.- Return type:
- Returns:
A data frame containing the points as rows with columns corresponding to the parameter names.
- Raises:
ValueError – If there are not enough points to sample from.
- to_json()¶
Create an object’s JSON representation.
- Return type:
- Returns:
The JSON representation as a string.
- transform(data: DataFrame)[source]¶
See
baybe.searchspace.discrete.SubspaceDiscrete.transform()
.
-
constraints_lin_eq:
list
[ContinuousLinearEqualityConstraint
]¶ List of linear equality constraints.
-
constraints_lin_ineq:
list
[ContinuousLinearInequalityConstraint
]¶ List of linear inequality constraints.
-
parameters:
list
[NumericalContinuousParameter
]¶ The list of parameters of the subspace.