Skip to content

ExperimentManager

Experimental data and noise.

experiment_manager

ExperimentManager

ExperimentManager(search_space=None, target_columns: Optional[List[str]] = None, variable_columns: Optional[List[str]] = None)

Class for storing and managing experimental data in a consistent way across backends. Provides methods for data access, saving/loading, and conversion to formats needed by different backends.

Supports both single-objective and multi-objective optimization: - Single-objective: Uses single target column (default: 'Output', but configurable) - Multi-objective: Uses multiple target columns specified in target_columns attribute

The target_column parameter allows flexible column naming to support various CSV formats.

set_search_space

set_search_space(search_space)

Set or update the search space reference.

add_experiment

add_experiment(point_dict: Dict[str, Union[float, str, int]], output_value: Optional[Union[float, Dict[str, float]]] = None, noise_value: Optional[float] = None, iteration: Optional[int] = None, reason: Optional[str] = None)

Add a single experiment point.

Parameters:

Name Type Description Default
point_dict Dict[str, Union[float, str, int]]

Dictionary with variable names as keys and values

required
output_value Optional[Union[float, Dict[str, float]]]

The experiment output/target value (if known). A float goes to the first target column; a dict {target: value} fills every target column it names (multi-objective).

None
noise_value Optional[float]

Optional noise variance (σ²) of the observation; the models use it as a variance (BoTorch train_Yvar, scikit-learn alpha), not a standard deviation

None
iteration Optional[int]

Iteration number (auto-assigned if None)

None
reason Optional[str]

Reason for this experiment (e.g., 'Initial Design (LHS)', 'Expected Improvement')

None

add_experiments_batch

add_experiments_batch(data_df: DataFrame)

Add multiple experiment points at once from a DataFrame.

get_data

get_data() -> pd.DataFrame

Get the raw experiment data.

metadata_columns

metadata_columns() -> list

Columns that are NOT model inputs: targets + bookkeeping metadata.

get_features_and_target

get_features_and_target() -> Tuple[pd.DataFrame, pd.Series]

Get features (X) and target (y) separated.

Returns:

Name Type Description
X DataFrame

Features DataFrame

y Series

Target Series

Raises:

Type Description
ValueError

If configured target column is not found in data

get_features_target_and_noise

get_features_target_and_noise() -> Tuple[pd.DataFrame, pd.Series, Optional[pd.Series]]

Get features (X), target (y), and noise variances if available.

Noise is a variance (σ²): BoTorch takes it as train_Yvar and scikit-learn as alpha, never as a standard deviation.

Returns:

Name Type Description
X DataFrame

Features DataFrame

y Series

Target Series

noise Optional[Series]

Series of per-row noise variances if available, otherwise None

Raises:

Type Description
ValueError

If configured target column is not found in data

get_features_and_targets_multi

get_features_and_targets_multi() -> Tuple[pd.DataFrame, pd.DataFrame, Optional[pd.DataFrame]]

Get features (X), all targets (Y), and optional noise variances (σ²) for multi-objective optimization.

Returns:

Name Type Description
X DataFrame

Features DataFrame (n_samples, n_features)

Y DataFrame

Targets DataFrame (n_samples, n_objectives) with columns = target names

noise Optional[DataFrame]

DataFrame of per-row noise variances if available, otherwise None

Raises:

Type Description
ValueError

If any target column is not found in data

has_noise_data

has_noise_data() -> bool

Check if the experiment data includes noise variances (a Noise column).

save_to_csv

save_to_csv(filepath: Optional[str] = None)

Save experiments to a CSV file.

Parameters:

Name Type Description Default
filepath Optional[str]

Path to save the file. If None, uses the previously used path.

None

load_from_csv

load_from_csv(filepath: str)

Load experiments from a CSV file.

Parameters:

Name Type Description Default
filepath str

Path to the CSV file

required

from_csv classmethod

from_csv(filepath: str, search_space=None)

Class method to create an ExperimentManager from a CSV file.

clear

clear()

Clear all experimental data.

get_full_history

get_full_history() -> pd.DataFrame

Get the full experiment history.

get_latest_experiment

get_latest_experiment() -> pd.Series

Get the most recently added experiment.

get_pareto_frontier

get_pareto_frontier(directions: Optional[List[str]] = None) -> pd.DataFrame

Compute Pareto-optimal solutions from experiments with multiple objectives.

Uses BoTorch's fast non-dominated sorting algorithm to identify Pareto-optimal points. Works with both single-objective (returns all data) and multi-objective experiments.

Parameters:

Name Type Description Default
directions Optional[List[str]]

List of 'maximize' or 'minimize' for each target column. If None, assumes all objectives are maximized. Length must match number of target columns.

None

Returns:

Type Description
DataFrame

DataFrame containing only Pareto-optimal experiments with all columns.

Raises:

Type Description
ValueError

If directions length doesn't match target columns.

ValueError

If target columns contain missing data.

Example
For 2 objectives: maximize yield, minimize cost

pareto_df = exp_mgr.get_pareto_frontier(['maximize', 'minimize'])

compute_hypervolume

compute_hypervolume(ref_point: Union[List[float], ndarray], directions: Optional[List[str]] = None) -> float

Compute hypervolume indicator for multi-objective experiments.

The hypervolume measures the volume of objective space dominated by the Pareto frontier relative to a reference point. Larger values indicate better overall performance.

Parameters:

Name Type Description Default
ref_point Union[List[float], ndarray]

Reference point (worst acceptable values) for each objective. Must have same length as target_columns. For maximization: should be below minimum observed values. For minimization: should be above maximum observed values.

required
directions Optional[List[str]]

List of 'maximize' or 'minimize' for each target column. If None, assumes all objectives are maximized.

None

Returns:

Type Description
float

Hypervolume value (float). Zero if no Pareto-optimal points exist.

Raises:

Type Description
ValueError

If ref_point length doesn't match target columns.

ValueError

If target columns contain missing data.

Example
For 2 objectives (maximize yield, minimize cost)
ref_point = [min_acceptable_yield, max_acceptable_cost]

hv = exp_mgr.compute_hypervolume([50.0, 100.0], ['maximize', 'minimize'])