Skip to content

Models

BoTorch and scikit-learn Gaussian process surrogates.

botorch_model

BoTorchModel

BoTorchModel(training_iter=50, random_state=42, kernel_options: dict = None, cat_dims: list[int] | None = None, search_space: list = None, input_transform_type: str = 'none', output_transform_type: str = 'none', categorical_values: Optional[Dict[str, List[Any]]] = None)

Bases: BaseModel

Initialize the BoTorchModel with custom options.

Parameters:

Name Type Description Default
training_iter

Maximum iterations for model optimization.

50
random_state

Random seed for reproducibility.

42
kernel_options dict

Dictionary with kernel options like "cont_kernel_type" and "matern_nu".

None
cat_dims list[int] | None

List of column indices that are categorical.

None
search_space list

Optional search space list.

None
input_transform_type str

Type of input scaling ("none", "normalize", "standardize")

'none'
output_transform_type str

Type of output scaling ("none", "standardize")

'none'
categorical_values Optional[Dict[str, List[Any]]]

Declared values per categorical column; labels are encoded by position in this list.

None

kernel property

kernel

Return a representation of the kernel for visualization purposes. This is a compatibility method to make the model work with the visualization system.

train

train(exp_manager, derived_feature_transform=None, **kwargs)

Train the model using an ExperimentManager instance.

predict

predict(X, return_std=False, **kwargs)

Make predictions using the trained model.

predict_with_std

predict_with_std(X)

Make predictions with standard deviation.

Parameters:

Name Type Description Default
X

Input features (DataFrame or array)

required

Returns:

Type Description

Tuple of (predictions, standard deviations)

evaluate

evaluate(experiment_manager, cv_splits=5, debug=False, progress_callback=None, **kwargs)

Evaluate model performance on increasing subsets of data using cross-validation. Uses the same approach as the parity plot to ensure consistent RMSE values.

get_hyperparameters

get_hyperparameters()

Get model hyperparameters.

generate_contour_data

generate_contour_data(x_range, y_range, fixed_values, x_idx=0, y_idx=2)

Generate contour plot data using the BoTorch model.

Parameters:

Name Type Description Default
x_range

Tuple of (min, max) for x-axis values

required
y_range

Tuple of (min, max) for y-axis values

required
fixed_values

Dict mapping dimension indices to fixed values

required
x_idx

Index of the x-axis dimension in the model input

0
y_idx

Index of the y-axis dimension in the model input

2

Returns:

Type Description

Tuple of (X, Y, Z) for contour plotting

evaluate_acquisition

evaluate_acquisition(X: Union[DataFrame, ndarray], acq_func: str = 'ucb', acq_func_kwargs: Optional[dict] = None, maximize: bool = True) -> Tuple[np.ndarray, None]

Evaluate acquisition function at given points using BoTorch functions.

Parameters:

Name Type Description Default
X Union[DataFrame, ndarray]

Points to evaluate (DataFrame or array with shape (n, d))

required
acq_func str

Acquisition function name Analytic: 'ei', 'logei', 'pi', 'logpi', 'ucb' Batch: 'qei', 'qucb', 'qnipv'

'ucb'
acq_func_kwargs Optional[dict]

Additional parameters (e.g., {'beta': 0.5, 'mc_samples': 128})

None
maximize bool

Whether we're maximizing (True) or minimizing (False)

True

Returns:

Type Description
Tuple[ndarray, None]

Tuple of (acq_values, None) - None because acq functions are deterministic

Example

points = pd.DataFrame({'temp': [300, 350, 400], 'pressure': [1, 2, 3]}) acq_vals, _ = model.evaluate_acquisition(points, acq_func='ei', maximize=True)

sklearn_model

SklearnModel

SklearnModel(kernel_options: dict, n_restarts_optimizer=30, random_state=42, optimizer='L-BFGS-B', input_transform_type: str = 'none', output_transform_type: str = 'none')

Bases: BaseModel

Initialize the SklearnModel with kernel options and scaling transforms.

Parameters:

Name Type Description Default
kernel_options dict

Dictionary with keys: - "kernel_type": one of "RBF", "Matern", "RationalQuadratic" - If "Matern" is selected, a key "matern_nu" should be provided.

required
n_restarts_optimizer

Number of restarts for the optimizer.

30
random_state

Random state for reproducibility.

42
optimizer

Optimization method for hyperparameter tuning.

'L-BFGS-B'
input_transform_type str

Type of input scaling ("none", "standard", "minmax", "robust")

'none'
output_transform_type str

Type of output scaling ("none", "standard", "minmax", "robust")

'none'

train

train(experiment_manager, **kwargs)

Train the model using the ExperimentManager.

predict

predict(X, return_std=False, **kwargs)

Make predictions using the trained model.

Parameters:

Name Type Description Default
X

Input features

required
return_std

Whether to return standard deviations

False

Returns:

Type Description

If return_std is False: numpy array of predictions

If return_std is True: tuple of (predictions, standard deviations)

predict_with_std

predict_with_std(X)

Make predictions with standard deviation.

Parameters:

Name Type Description Default
X

Input features (DataFrame or array)

required

Returns:

Type Description

Tuple of (predictions, standard deviations)

generate_contour_data

generate_contour_data(x_range, y_range, fixed_values, x_idx=0, y_idx=1)

Generate contour plot data for the sklearn model with proper scaling.

Parameters:

Name Type Description Default
x_range

Tuple of (min, max) for x-axis values in original scale

required
y_range

Tuple of (min, max) for y-axis values in original scale

required
fixed_values

Dict mapping dimension indices to fixed values in original scale

required
x_idx

Index of the x-axis dimension

0
y_idx

Index of the y-axis dimension

1

Returns:

Type Description

Tuple of (X, Y, Z) for contour plotting in original scale

evaluate_acquisition

evaluate_acquisition(X: Union[DataFrame, ndarray], acq_func: str = 'ucb', acq_func_kwargs: Optional[dict] = None, maximize: bool = True) -> Tuple[np.ndarray, None]

Evaluate acquisition function at given points using skopt functions.

Parameters:

Name Type Description Default
X Union[DataFrame, ndarray]

Points to evaluate (DataFrame or array with shape (n, d))

required
acq_func str

Acquisition function name ('ei', 'pi', 'ucb/lcb')

'ucb'
acq_func_kwargs Optional[dict]

Additional parameters (e.g., {'xi': 0.01, 'kappa': 1.96})

None
maximize bool

Whether we're maximizing (True) or minimizing (False)

True

Returns:

Type Description
Tuple[ndarray, None]

Tuple of (acq_values, None) - None because acq functions are deterministic

Example

points = pd.DataFrame({'temp': [300, 350, 400], 'pressure': [1, 2, 3]}) acq_vals, _ = model.evaluate_acquisition(points, acq_func='ei', maximize=True)