ExpDesigner#

class obsidian.experiment.design.ExpDesigner(X_space: ParamSpace, seed: int | None = None)[source]#

Bases: object

ExpDesigner is a base class for designing experiments in a parameter space.

X_space#

The parameter space for the experiment.

Type:

ParamSpace

seed#

The randomization seed.

Type:

int | None

Raises:

TypeError – If X_space is not an obsidian ParamSpace object.

__init__(X_space: ParamSpace, seed: int | None = None)[source]#

Methods

__init__(X_space[, seed])

initialize([m_initial, method, sample_custom])

Initializes the experiment design.

load_state(obj_dict[, X_space, seed])

Reconstruct an ExpDesigner from a saved state dictionary.

save_state()

Save the designer state to a JSON-safe dictionary.

initialize(m_initial: int | None = None, method: str = 'LHS', sample_custom: Tensor | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None) DataFrame[source]#

Initializes the experiment design.

Parameters:
  • m_initial (int) – The number of experiments to initialize.

  • method (str, optional) – The method to use for initialization. Defaults to 'LHS'.

  • sample_custom (Tensor | ArrayLike | None, optional) – Custom samples for initialization. Defaults to None.

Returns:

The initialized experiment design.

Return type:

pd.DataFrame

Raises:
  • KeyError – If method is not one of the supported methods.

  • ValueError – If sample_custom is None when method is ‘Custom’.

  • ValueError – If the number of columns in sample_custom does not match the size of the feature space.

classmethod load_state(obj_dict: dict, X_space=None, seed: int | None = None) ExpDesigner[source]#

Reconstruct an ExpDesigner from a saved state dictionary.

Parameters:
  • obj_dict (dict) – Output of save_state().

  • X_space – Override for the parameter space. When provided (typically by Campaign.load_state()), the X_space payload in obj_dict is ignored. Defaults to None.

  • seed (int | None, optional) – Override for the seed. When provided, obj_dict['seed'] is ignored. Defaults to None.

Returns:

A new designer instance equivalent to the saved one.

Return type:

ExpDesigner

save_state() dict[source]#

Save the designer state to a JSON-safe dictionary.

Returns:

Dictionary with keys name, X_space and seed.

Return type:

dict