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

parameters

The list of parameters of the subspace.

constraints_lin_eq

List of linear equality constraints.

constraints_lin_ineq

List of linear inequality constraints.

full_factorial

Get the full factorial of the continuous space.

is_empty

Return whether this subspace is empty.

param_bounds_comp

Return bounds as numpy array.

param_names

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 empty()[source]

Create an empty continuous subspace.

Return type:

SubspaceContinuous

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:

SubspaceContinuous

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:
Return type:

SubspaceContinuous

Returns:

The created continuous subspace.

classmethod from_dict(dictionary: dict)

Create an object from its dictionary representation.

Parameters:

dictionary (dict) – The dictionary representation.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

classmethod from_json(string: str)

Create an object from its JSON representation.

Parameters:

string (str) – The JSON representation of the object.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

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:

DataFrame

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.

samples_random(n_points: int = 1)[source]

Get random point samples from the continuous space.

Parameters:

n_points (int) – Number of points that should be sampled.

Return type:

DataFrame

Returns:

A data frame containing the points as rows with columns corresponding to the parameter names.

to_dict()

Create an object’s dictionary representation.

Return type:

dict

to_json()

Create an object’s JSON representation.

Return type:

str

Returns:

The JSON representation as a string.

transform(data: DataFrame)[source]

See baybe.searchspace.discrete.SubspaceDiscrete.transform().

Parameters:

data (DataFrame) – The data that should be transformed.

Return type:

DataFrame

Returns:

The transformed data.

constraints_lin_eq: list[ContinuousLinearEqualityConstraint]

List of linear equality constraints.

constraints_lin_ineq: list[ContinuousLinearInequalityConstraint]

List of linear inequality constraints.

property full_factorial: DataFrame

Get the full factorial of the continuous space.

property is_empty: bool

Return whether this subspace is empty.

property param_bounds_comp: ndarray

Return bounds as numpy array.

property param_names: list[str]

Return list of parameter names.

parameters: list[NumericalContinuousParameter]

The list of parameters of the subspace.