Campaign#
- 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:
objectBase class for tracking optimization progress and other metrics over multiple iterations.
- X_space#
 The parameter space for the campaign.
- Type:
 
- data#
 The data collected during the campaign.
- Type:
 pd.DataFrame
- designer#
 The experimental designer used for experiment design.
- Type:
 
- 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
- __init__(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]#
 
Methods
__init__(X_space, target[, constraints, ...])add_data(df)Adds data to the campaign.
Clears campaign data
Clears the campaign objective function
Clears output constraints
constrain_outputs(constraints)Sets optional output constraints for the campaign.
evaluate(X_suggest)Maps Optimizer.evaluate method
fit()Maps Optimizer.fit method
initialize(**design_kwargs)Maps ExpDesigner.initialize method
load_state(obj_dict)Loads the state of the campaign from a dictionary.
Saves the state of the Campaign object as a dictionary.
set_X_space(X_space)Sets the campaign ParamSpace
set_designer(designer)Sets the campaign experiment designer
set_objective(objective)(Re)sets the campaign objective function
set_optimizer(optimizer)Sets the campaign optimizer
set_target(target)Sets the experimental target context for the campaign.
suggest(**optim_kwargs)Maps Optimizer.suggest method
Attributes
Feature columns of the training data
Best performing X values
Campaign ParamSpace
Campaign Experimental Designer
Experimental response data, in transformed space
Number of observations in training data
Objective function evaluated on f
Campaign Objective function
Campaign Optimizer
Returns the objective function as appropriate, else the response data
Maximum response data in training set
Campaign experimental target(s)
Experimental response data
- 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
- constrain_outputs(constraints: Output_Constraint | list[Output_Constraint] | None) None[source]#
 Sets optional output constraints for the campaign.
- property designer: ExpDesigner#
 Campaign Experimental Designer
- 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
- property m_exp: int#
 Number of observations in training data
- property o: Series | DataFrame#
 Objective function evaluated on f
- 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_target(target: Target | list[Target])[source]#
 Sets the experimental target context for the campaign.
- property target#
 Campaign experimental target(s)
- property y: Series | DataFrame#
 Experimental response data