campaign#

Campaign class definition

Classes

Campaign(X_space, target[, constraints, ...])

Base class for tracking optimization progress and other metrics over multiple iterations.

class obsidian.campaign.campaign.Campaign(X_space: ParamSpace, target: Target | list[Target], constraints: Output_Constraint | list[Output_Constraint] | None = None, optimizer: Optimizer | None = None, designer: ExpDesigner | None = None, objective: Objective | None = None, seed: int | None = None)[source]#

Bases: object

Base class for tracking optimization progress and other metrics over multiple iterations.

X_space#

The parameter space for the campaign.

Type:

ParamSpace

data#

The data collected during the campaign.

Type:

pd.DataFrame

optimizer#

The optimizer used for optimization.

Type:

Optimizer

designer#

The experimental designer used for experiment design.

Type:

ExpDesigner

iter#

The current iteration number.

Type:

int

seed#

The seed for random number generation.

Type:

int

Properties:

m_exp (int): The number of observations in campaign.data y (pd.Series): The response data in campaign.data y_names (list): The names of the response data columns f (pd.Series): The transformed response data o (pd.Series): The objective function evaluated on f o_names (list): The names of the objective function columns X (pd.DataFrame): The input features of campaign.data response_max (float | pd.Series): The maximum for each response target (Target | list[Target]): The target(s) for optimization. objective (Objective, optional): The objective of the optimization campaign

property X: DataFrame#

Feature columns of the training data

property X_best: DataFrame#

Best performing X values

property X_space: ParamSpace#

Campaign ParamSpace

add_data(df: DataFrame)[source]#

Adds data to the campaign.

Parameters:

Z_i (pd.DataFrame) – The data to be added to the campaign.

Raises:
  • KeyError – If all X_names are not in the dataset

  • KeyError – If all y_names are not in the dataset

clear_data()[source]#

Clears campaign data

clear_objective()[source]#

Clears the campaign objective function

clear_output_constraints()[source]#

Clears output constraints

constrain_outputs(constraints: Output_Constraint | list[Output_Constraint] | None) None[source]#

Sets optional output constraints for the campaign.

property designer: ExpDesigner#

Campaign Experimental Designer

evaluate(X_suggest: DataFrame)[source]#

Maps Optimizer.evaluate method

property f: Series | DataFrame#

Experimental response data, in transformed space

fit()[source]#

Maps Optimizer.fit method

Raises:

ValueError – If no data has been registered to the campaign

initialize(**design_kwargs)[source]#

Maps ExpDesigner.initialize method

classmethod load_state(obj_dict: dict)[source]#

Loads the state of the campaign from a dictionary.

Parameters:
  • cls (Campaign) – The class object.

  • obj_dict (dict) – A dictionary containing the campaign state.

Returns:

A new campaign object with the loaded state.

Return type:

Campaign

property m_exp: int#

Number of observations in training data

property o: Series | DataFrame#

Objective function evaluated on f

property objective: Objective | None#

Campaign Objective function

property optimizer: Optimizer#

Campaign Optimizer

property out: Series | DataFrame#

Returns the objective function as appropriate, else the response data

property response_max: float | Series#

Maximum response data in training set

save_state() dict[source]#

Saves the state of the Campaign object as a dictionary.

Returns:

A dictionary containing the saved state of the Campaign object.

Return type:

dict

set_X_space(X_space: ParamSpace)[source]#

Sets the campaign ParamSpace

set_designer(designer: ExpDesigner)[source]#

Sets the campaign experiment designer

set_objective(objective: Objective | None)[source]#

(Re)sets the campaign objective function

set_optimizer(optimizer: Optimizer)[source]#

Sets the campaign optimizer

set_target(target: Target | list[Target])[source]#

Sets the experimental target context for the campaign.

Parameters:

target (Target | list[Target] | None) – The target or list of targets to set.

suggest(**optim_kwargs)[source]#

Maps Optimizer.suggest method

property target#

Campaign experimental target(s)

property y: Series | DataFrame#

Experimental response data