nextorch.bo

Imports Gaussian Processes (GP) and Bayesian Optimization (BO) methods from BoTorch

Contains all Experiment classes

class nextorch.bo.BasicExperiment(name: Optional[str] = 'simple_experiment')

BasicExperiment class Base: Database The generic class for the experiment classes Handles prediction and running the next trial

assign_weights(Y_weights: Optional[Union[list, nextorch.utils.Array, torch.Tensor]] = None)

Assign weights to each objective Y

Parameters

Y_weights (Optional[ArrayLike1d], optional) – Weights assigned to each objective Y, sums to 1 by default None, each objective is treated equally

fit_model()

Train a GP model given X, Y and the sign of Y

predict(X_test: Union[list, nextorch.utils.Matrix, torch.Tensor], show_confidence: Optional[bool] = False) Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]]

Use GP model for prediction at X_test

Parameters
  • X_test (MatrixLike2d) – X matrix in a unit scale used for testing, must have the same dimension as X for training

  • show_confidence (Optional[bool], optional) – by default False, only return posterior mean If True, return the mean, and lower, upper confidence interval

Returns

  • Y_test (Tensor) – The mean of postierior

  • Y_test_lower (Tensor, optional) – The lower confidence interval

  • Y_test_upper (Tensor, optional) – The upper confidence interval

predict_real(X_test: Union[list, nextorch.utils.Matrix, torch.Tensor], show_confidence: Optional[bool] = False) Union[nextorch.utils.Matrix, Tuple[nextorch.utils.Matrix, nextorch.utils.Matrix, nextorch.utils.Matrix]]

Use GP model for prediction at X_test

Parameters
  • X_test (MatrixLike2d) – X matrix in a real scale used for testing, must have the same dimension as X for training

  • show_confidence (Optional[bool], optional) – by default False, only return posterior mean If True, return the mean, and lower, upper confidence interval

Returns

  • Y_test_real (numpy matrix) – predictions in a real scale

  • Y_test_lower_real (numpy matrix) – The lower confidence interval in a real scale

  • Y_test_upper_real (numpy matrix) – The upper confidence interval in a real scale

run_trial(X_new: Union[list, nextorch.utils.Matrix, torch.Tensor], X_new_real: nextorch.utils.Matrix, Y_new_real: Optional[nextorch.utils.Matrix] = None) torch.Tensor

Run trial candidate points Fit the GP model to new data

Parameters
  • X_new (MatrixLike2d) – The new candidate point matrix

  • X_new_real (Matrix) – The new candidate point matrix in a real scale

  • Y_new_real (Matrix) – Experimental reponse values

Returns

Y_new – values of reponses at the new point values

Return type

Tensor

run_trials_auto(n_trials: int, acq_func_name: Optional[str] = 'EI')

Automated optimization loop with one infill point added per loop When objective function is defined, responses are obtained from the objective function otherwise, from the GP model

Parameters
  • n_trials (int) – Number of optimization loops one infill point is added per loop

  • acq_func_name (Optional[str], optional) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB” by default ‘EI’

set_optim_specs(objective_func: Optional[object] = None, model: Optional[botorch.models.model.Model] = None, maximize: Optional[bool] = True, Y_weights: Optional[Union[list, nextorch.utils.Array, torch.Tensor]] = None)

Set the specs for Bayseian Optimization

Parameters
  • objective_func (Optional[object], by default None) – objective function that is being optimized

  • model (Optional['botorch.models.model.Model'_], optional) – pre-trained GP model, by default None

  • maximize (Optional[bool], optional) – by default True, maximize the objective function Otherwise False, minimize the objective function

  • Y_weights (Optional[ArrayLike1d], optional) – Weights assigned to each objective Y, sums to 1 by default None, each objective is treated equally

:param : :type : _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

validate_training(show_confidence: Optional[bool] = False) Union[nextorch.utils.Matrix, Tuple[nextorch.utils.Matrix, nextorch.utils.Matrix, nextorch.utils.Matrix]]

Use GP model for prediction at training X Y_real is used to compare with Y from objective function

Parameters

show_confidence (Optional[bool], optional) – by default False, only return posterior mean If True, return the mean, and lower, upper confidence interval

Returns

  • Y_test_real (numpy matrix) – predictions in a real scale

  • Y_test_lower_real (numpy matrix) – The lower confidence interval in a real scale

  • Y_test_upper_real (numpy matrix) – The upper confidence interval in a real scale

class nextorch.bo.COMSOLExperiment(name: Optional[str] = 'simple_experiment')

COMSOLExperiment class Base: Experiment Experiment consists of a set of trial points using COMSOL For single objective optimization

comsol_simulation(X_new_real)

Run COMSOL simulation

Parameters

X_new_real (MatrixLike2d) – The new point in a real scale

input_data(X_real: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_real: Union[list, nextorch.utils.Matrix, torch.Tensor], X_names: List[str], X_units: List[str], Y_names: Optional[List[str]] = None, Y_units: Optional[List[str]] = None, standardized: Optional[bool] = False, X_ranges: Optional[Union[list, nextorch.utils.Matrix, torch.Tensor]] = None, unit_flag: Optional[bool] = False, log_flags: Optional[list] = None, decimals: Optional[int] = None)

Input data into Experiment object

Parameters
  • X_real (MatrixLike2d) – original independent data in a real scale

  • Y_real (MatrixLike2d) – original dependent data in a real scale

  • X_names (List[str]) – Names of independent varibles

  • X_units (List[str]) – Units of independent varibles

  • Y_names (Optional[List[str]]) – Names of dependent varibles

  • Y_units (Optional[List[str]]) – Units of dependent varibles

  • standardized (Optional[bool], optional) – by default False, the input Y is standardized if true, skip processing

  • X_ranges (Optional[MatrixLike2d], optional) – list of x ranges, by default None

  • unit_flag (Optional[bool], optional,) – by default, False If true, the X is in a unit scale so the function is used to scale X to a log scale

  • log_flags (Optional[list], optional) – list of boolean flags True: use the log scale on this dimensional False: use the normal scale by default []

  • decimals (Optional[int], optional) – Number of decimal places to keep by default None, i.e. no rounding up

set_optim_specs(objective_file_name: str, comsol_location: str, comsol_output_location: str, comsol_output_col: Optional[int] = 2, model: Optional[botorch.models.model.Model] = None, maximize: Optional[bool] = True, Y_weights: Optional[Union[list, nextorch.utils.Array, torch.Tensor]] = None)

Set the specs for Bayseian Optimization

Parameters
  • objective_file_name (str) – the objective COMSOL file

  • comsol_location (str) – the location COMSOL installed

  • comsol_output_location (str) – the location of saved COMSOL output should be a text file

  • comsol_output_col (int) – the column number of the objective

  • model (Optional['botorch.models.model.Model'_], optional) – pre-trained GP model, by default None

  • maximize (Optional[bool], optional) – by default True, maximize the objective function Otherwise False, minimize the objective function

  • Y_weights (Optional[ArrayLike1d], optional) – Weights assigned to each objective Y, sums to 1 by default None, each objective is treated equally

:param : :type : _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

class nextorch.bo.COMSOLMOOExperiment(name: Optional[str] = 'simple_experiment')

COMSOLMOOExperiment class Base: EHVIMOOExperiment For multi-objective optimization (MOO) Used for generating Pareto front

comsol_simulation(X_new_real)

Run COMSOL simulation

Parameters

X_new_real (MatrixLike2d) – The new point in a real scale

input_data(X_real: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_real: Union[list, nextorch.utils.Matrix, torch.Tensor], X_names: List[str], X_units: List[str], Y_names: Optional[List[str]] = None, Y_units: Optional[List[str]] = None, standardized: Optional[bool] = False, X_ranges: Optional[Union[list, nextorch.utils.Matrix, torch.Tensor]] = None, unit_flag: Optional[bool] = False, log_flags: Optional[list] = None, decimals: Optional[int] = None)

Input data into Experiment object

Parameters
  • X_real (MatrixLike2d) – original independent data in a real scale

  • Y_real (MatrixLike2d) – original dependent data in a real scale

  • X_names (Optional[List[str]]) – Names of independent varibles

  • X_units (Optional[List[str]]) – Units of independent varibles

  • Y_names (Optional[List[str]]) – Names of dependent varibles

  • Y_units (Optional[List[str]]) – Units of dependent varibles

  • standardized (Optional[bool], optional) – by default False, the input data will be standardized if true, skip processing

  • X_ranges (Optional[MatrixLike2d], optional) – list of x ranges, by default None

  • unit_flag (Optional[bool], optional,) – by default, False If true, the X is in a unit scale so the function is used to scale X to a log scale

  • log_flags (Optional[list], optional) – list of boolean flags True: use the log scale on this dimensional False: use the normal scale by default []

  • decimals (Optional[int], optional) – Number of decimal places to keep by default None, i.e. no rounding up

set_optim_specs(objective_file_name: str, comsol_location: str, comsol_output_location: str, comsol_output_col: Optional[List[int]] = [2, 3], model: Optional[botorch.models.model.Model] = None, maximize: Optional[bool] = True, Y_weights: Optional[Union[list, nextorch.utils.Array, torch.Tensor]] = None)

Set the specs for Bayseian Optimization

Parameters
  • objective_file_name (str) – the objective COMSOL file

  • comsol_location (str) – the location COMSOL installed

  • comsol_output_location (str) – the location of saved COMSOL output should be a text file

  • comsol_output_col (List[int]) – the column number of the objective

  • model (Optional['botorch.models.model.Model'_], optional) – pre-trained GP model, by default None

  • maximize (Optional[bool], optional) – by default True, maximize the objective function Otherwise False, minimize the objective function

  • Y_weights (Optional[ArrayLike1d], optional) – Weights assigned to each objective Y, sums to 1 by default None, each objective is treated equally

:param : :type : _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

class nextorch.bo.Database(name: Optional[str] = 'simple_experiment')

Database class The base class for the experiment classes Handles data input and directory setup

define_space(parameters: Union[nextorch.parameter.Parameter, List[nextorch.parameter.Parameter]])

Define the parameter space

Parameters

parameters (Union[Parameter, List[Parameter]]) – A single or a list of parameters

encode_X(X_unit: Union[list, nextorch.utils.Matrix, torch.Tensor]) Tuple[Union[list, nextorch.utils.Matrix, torch.Tensor], Union[list, nextorch.utils.Matrix, torch.Tensor]]

Encode X from the relax continuous space in a unit scale to the encoding space

Parameters

X_unit (MatrixLike2d) – original X in a unit scale

Returns

  • X_encode (MatrixLike2d) – Encoded X in a unit scale

  • X_real (MatrixLike2d) – Encoded X in a real scale

input_data(X_real: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_real: Union[list, nextorch.utils.Matrix, torch.Tensor], X_names: Optional[List[str]] = None, Y_names: Optional[List[str]] = None, standardized: Optional[bool] = False, X_ranges: Optional[Union[list, nextorch.utils.Matrix, torch.Tensor]] = None, unit_flag: Optional[bool] = False, log_flags: Optional[list] = None, decimals: Optional[int] = None)

Input data into Experiment object

Parameters
  • X_real (MatrixLike2d) – original independent data in a real scale

  • Y_real (MatrixLike2d) – original dependent data in a real scale

  • X_names (Optional[List[str]], optional) – Names of independent varibles, by default None

  • Y_names (Optional[List[str]], optional) – Names of dependent varibles, by default None

  • standardized (Optional[bool], optional) – by default False, the input Y is standardized if true, skip processing

  • X_ranges (Optional[MatrixLike2d], optional) – list of x ranges, by default None

  • unit_flag (Optional[bool], optional,) – by default, False If true, the X is in a unit scale so the function is used to scale X to a log scale

  • log_flags (Optional[list], optional) – list of boolean flags True: use the log scale on this dimensional False: use the normal scale by default []

  • decimals (Optional[int], optional) – Number of decimal places to keep by default None, i.e. no rounding up

preprocess_data(X_real: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_real: Union[list, nextorch.utils.Matrix, torch.Tensor], standardized: Optional[bool] = False, unit_flag: Optional[bool] = False, log_flags: Optional[list] = None, decimals: Optional[int] = None)

Preprocesses input data and assigns the variables to self

Parameters
  • X_real (MatrixLike2d) – original independent data in a real scale

  • Y_real (MatrixLike2d) – original dependent data in a real scale

  • standardized (Optional[bool], optional) – by default False, the input Y is standardized if true, skip processing

  • X_ranges (Optional[MatrixLike2d], optional) – list of x ranges, by default None

  • unit_flag (Optional[bool], optional,) – by default, False If true, the X is in a unit scale (from DOE)

  • log_flags (Optional[list], optional) – list of boolean flags True: use the log scale on this dimensional False: use the normal scale by default []

  • decimals (Optional[int], optional) – Number of decimal places to keep by default None, i.e. no rounding up

class nextorch.bo.EHVIMOOExperiment(name: Optional[str] = 'simple_experiment')

EHVIMOOExperiment class Base: Experiment For multi-objective optimization (MOO)

generate_next_point(acq_func_name: Optional[str] = 'qEHVI', n_candidates: Optional[int] = 1, eta: Optional[float] = 0.001, **kwargs) Tuple[torch.Tensor, nextorch.utils.Matrix, botorch.acquisition.AcquisitionFunction]

Generate the next trial point(s) using qEHVI

Parameters
  • acq_func_name (Optional[str], optional) – Name of the acquisition function by default ‘qEHVI’

  • n_candidates (Optional[int], optional) – Number of candidate points, by default 1 The point maximizes the acqucision function

  • eta (Optional[float], optional) – hyperparameter used in qEHVI, by default 0.001

  • arguments (**kwargs:keyword) – Other parameters used by ‘botorch.acquisition’_

Returns

  • X_new (Tensor) – where the acquisition function is optimized A new trial shall be run at this point

  • X_new (Matrix) – The new point in a real scale

  • acq_func (AcquisitionFunction) – Current acquisition function, can be used for plotting

  • .._’botorch.acquisition’ (https://botorch.org/api/acquisition.html)

get_optim() Tuple[Union[list, nextorch.utils.Array, torch.Tensor], Union[list, nextorch.utils.Array, torch.Tensor]]

Get the optimal response and conditions from the model

Returns

  • y_real_opt (ArrayLike1d) – Optimal response

  • X_real_opt (ArrayLike1d) – parameters or independent variable values at the optimal poinrt

set_ref_point(ref_point: Union[list, nextorch.utils.Array, torch.Tensor])

Set the reference point

Parameters

ref_point (ArrayLike1d) – reference point for the objectives

class nextorch.bo.Experiment(name: Optional[str] = 'simple_experiment')

Experiment class Base: BasicExperiment Experiment consists of a set of trial points For single objective optimization

generate_next_point(acq_func_name: Optional[str] = 'EI', n_candidates: Optional[int] = 1, beta: Optional[float] = 0.2, **kwargs) Tuple[torch.Tensor, nextorch.utils.Matrix, botorch.acquisition.AcquisitionFunction]

Generate the next trial point(s)

Parameters
  • acq_func_name (Optional[str], optional) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB” by default ‘EI’

  • n_candidates (Optional[int], optional) – Number of candidate points, by default 1 The point maximizes the acqucision function

  • beta (Optional[float], optional) – hyperparameter used in UCB, by default 0.2

  • arguments (**kwargs:keyword) – Other parameters used by ‘botorch.acquisition’_

Returns

  • X_new (Tensor) – where the acquisition function is optimized A new trial shall be run at this point

  • X_new (Matrix) – The new point in a real scale

  • acq_func (AcquisitionFunction) – Current acquisition function, can be used for plotting

  • .._’botorch.acquisition’ (https://botorch.org/api/acquisition.html)

get_optim() Tuple[float, Union[list, nextorch.utils.Array, torch.Tensor], int]

Get the optimal response and conditions from the model

Returns

  • y_real_opt (float) – Optimal response

  • X_real_opt (ArrayLike1d) – parameters or independent variable values at the optimal poinrt

  • index_opt (int) – Index of optimal point, zero indexing

update_bestseen() torch.Tensor

Calculate the best seen value in Y

Returns

best_value_scalar – a scalar saved in Tensor object

Return type

Tensor

class nextorch.bo.SingleWeightedExperiment(name: Optional[str] = 'simple_experiment')

WeightedExperiment class Base: BasicExperiment Experiments with weighted objectives

generate_next_point(acq_func_name: Optional[str] = 'EI', n_candidates: Optional[int] = 1, beta: Optional[float] = 0.2, **kwargs) Tuple[torch.Tensor, nextorch.utils.Matrix, botorch.acquisition.AcquisitionFunction]

Generate the next trial point(s)

Parameters
  • acq_func_name (Optional[str], optional) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB” by default ‘EI’

  • n_candidates (Optional[int], optional) – Number of candidate points, by default 1 The point maximizes the acqucision function

  • beta (Optional[float], optional) – hyperparameter used in UCB, by default 0.2

  • arguments (**kwargs:keyword) – Other parameters used by ‘botorch.acquisition’_

Returns

  • X_new (Tensor) – where the acquisition function is optimized A new trial shall be run at this point

  • X_new_real (Matrix) – The new point in a real scale

  • acq_func (AcquisitionFunction) – Current acquisition function, can be used for plotting

  • .._’botorch.acquisition’ (https://botorch.org/api/acquisition.html)

get_weighted_optim() Tuple[float, Union[list, nextorch.utils.Array, torch.Tensor], int]

Get the weighted optimal response and conditions from the model

Returns

  • y_real_opt (float) – Optimal response

  • X_real_opt (ArrayLike1d) – parameters or independent variable values at the optimal point

  • index_opt (int) – Index of optimal point, zero indexing

update_bestseen() torch.Tensor

Calculate the best seen value in Y

Returns

best_value_scalar – a scalar saved in Tensor object

Return type

Tensor

class nextorch.bo.WeightedMOOExperiment(name: Optional[str] = 'MOO_experiment')

MOOExperiment class Base: Database For multi-objective optimization (MOO) Currently, only supports two objectives Used for generating Pareto front

get_optim() Tuple[nextorch.utils.Matrix, nextorch.utils.Matrix]

Get the optimal Pareto set

Returns

  • y_real_opt (Matrix) – set of optimal response at each weight combination

  • X_real_opt (Matrix) – set of parameters or independent variable values at each weight combination

run_exp_auto(n_trials: int, acq_func_name: Optional[str] = 'EI') Union[list, nextorch.utils.Matrix, torch.Tensor]

run each experiments with Bayesian Optimization Extract the optimum points of each experiment

Parameters
  • n_trials (int) – Number of optimization loops one infill point is added per loop

  • acq_func_name (Optional[str], optional) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB” by default ‘EI’

Returns

Y_real_opts – Optimum values given each weight pair

Return type

MatrixLike2d

set_optim_specs(weights: Union[list, nextorch.utils.Array, torch.Tensor, float], objective_func: Optional[object] = None, maximize: Optional[bool] = True)

Set the specs for Pareto front Optimization

Parameters
  • weights (ArrayLike1d) – List of weights for objective 1 between 0 and 1

  • objective_func (Optional[object], by default None) – objective function that is being optimized

  • maximize (Optional[bool], optional) – by default True, maximize the objective function Otherwise False, minimize the objective function

:param : :type : _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

nextorch.bo.acq_dict = {'EI': botorch.acquisition.analytic.ExpectedImprovement, 'PI': botorch.acquisition.analytic.ProbabilityOfImprovement, 'UCB': botorch.acquisition.analytic.UpperConfidenceBound, 'qEHVI': botorch.acquisition.multi_objective.monte_carlo.qExpectedHypervolumeImprovement, 'qEI': botorch.acquisition.monte_carlo.qExpectedImprovement, 'qPI': botorch.acquisition.monte_carlo.qProbabilityOfImprovement, 'qUCB': botorch.acquisition.monte_carlo.qUpperConfidenceBound}

Keys are the names, values are the BoTorch objects

Type

dict

nextorch.bo.create_and_fit_gp(X: torch.Tensor, Y: torch.Tensor) botorch.models.model.Model

Creates a GP model to fit the data

Parameters
  • X (Tensor) – Independent data

  • Y (Tensor) – Depedent data

Returns

  • model (‘botorch.models.model.Model’_) – A single task GP, fit to X and Y

  • _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

nextorch.bo.eval_acq_func(acq_func: botorch.acquisition.AcquisitionFunction, X_test: Union[list, nextorch.utils.Matrix, torch.Tensor], return_type: Optional[str] = 'tensor') Union[list, nextorch.utils.Matrix, torch.Tensor]

Evaluate acquisition function at test values

Parameters
  • acq_func ('botorch.acquisition.AcquisitionFunction'_) – acquisition function object

  • X_test (MatrixLike2d) – X matrix used for testing, must have the same dimension as X for training

  • return_type (Optional[str], optional) – either ‘tensor’ or ‘np’ by default ‘tensor’

Returns

acq_val_test – acquisition function value at X_test

Return type

MatrixLike2d

Raises
nextorch.bo.eval_objective_func(X_unit: Union[list, nextorch.utils.Matrix, torch.Tensor], X_range: Union[list, nextorch.utils.Matrix, torch.Tensor], objective_func: object, return_type: Optional[str] = 'tensor') Union[list, nextorch.utils.Matrix, torch.Tensor]

Evaluate the objective function

Parameters
  • X_unit (MatrixLike2d, matrix or 2d tensor) – X in a unit scale

  • X_range (MatrixLike2d, matrix or 2d tensor) – list of x ranges

  • objective_func (function object) – a objective function to optimize

  • return_type (Optional[str], optional) – either ‘tensor’ or ‘np’ by default ‘tensor’

Returns

Y – model predicted values

Return type

MatrixLike2d

Raises

ValueError – if input return_type not defined

nextorch.bo.eval_objective_func_encoding(X_unit: Union[list, nextorch.utils.Matrix, torch.Tensor], parameter_space: Union[list, nextorch.utils.Matrix, torch.Tensor], objective_func: object, return_type: Optional[str] = 'tensor') Union[list, nextorch.utils.Matrix, torch.Tensor]

Evaluate the objective function

Parameters
  • X_unit (MatrixLike2d, matrix or 2d tensor) – X in a unit scale

  • X_range (MatrixLike2d, matrix or 2d tensor) – list of x ranges

  • objective_func (function object) – a objective function to optimize

  • return_type (Optional[str], optional) – either ‘tensor’ or ‘np’ by default ‘tensor’

Returns

Y – model predicted values

Return type

MatrixLike2d

Raises

ValueError – if input return_type not defined

nextorch.bo.fit_with_new_observations(model: botorch.models.model.Model, X: torch.Tensor, Y: torch.Tensor) botorch.models.model.Model

Fit the model with new observation

Parameters
  • model ('botorch.models.model.Model'_) – a single task GP

  • Xs (Tensor) – Independent data, new observation

  • Ys (Tensor) – Dependent data, new observation

Returns

  • model (‘botorch.models.model.Model’_) – A single task GP, fit to X and Y

  • _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model

nextorch.bo.get_acq_func(model: botorch.models.model.Model, acq_func_name: str, beta: Optional[float] = 0.2, best_f: Optional[float] = 1.0, objective: Optional[botorch.acquisition.objective.AcquisitionObjective] = None, **kwargs) botorch.acquisition.AcquisitionFunction

Get a specific type of acqucision function

Parameters
  • model ('botorch.models.model.Model'_) – A GP model

  • acq_func_name (str) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB”

  • beta (Optional[float], optional) – hyperparameter used in UCB, by default 0.2

  • best_f (Optional[float], optional) – best value seen so far used in PI and EI, by default 1.0

  • objective (Optional['botorch.acquisition.objective.AcquisitionObjective'_], optional) – Linear objective constructed from a weight vector, Used for multi-ojective optimization

  • arguments (**kwargs:keyword) – Other parameters used by ‘botorch.acquisition’_

Returns

acq_func – acquisition function object

Return type

‘botorch.acquisition.AcquisitionFunction’_

Raises
nextorch.bo.get_top_k_candidates(acq_func: botorch.acquisition.AcquisitionFunction, acq_func_name: str, bounds: torch.Tensor, k: Optional[int] = 1) torch.Tensor

Return the top k candidates which maximize the acqusicition function value

Parameters
  • acq_func ('botorch.acquisition.AcquisitionFunction'_) – acquisition function object

  • acq_func_name (str) – Name of the acquisition function Must be one of “EI”, “PI”, “UCB”, “qEI”, “qPI”, “qUCB”, “qEHVI”

  • bounds (Tensor) – Bounds of each X

  • k (Optional[int], optional) – number of candidates, by default 1

Returns

  • X_new (Tensor) – Top k candidate points, shape of n_dim * k

  • .._’botorch.acquisition.AcquisitionFunction’ (https://botorch.org/api/acquisition.html)

nextorch.bo.model_predict(model: botorch.models.model.Model, X_test: Union[list, nextorch.utils.Matrix, torch.Tensor], return_type: Optional[str] = 'tensor', negate_Y: Optional[bool] = False) Tuple[Union[list, nextorch.utils.Matrix, torch.Tensor], Union[list, nextorch.utils.Matrix, torch.Tensor], Union[list, nextorch.utils.Matrix, torch.Tensor]]

Makes standardized prediction at X_test using the GP model

Parameters
  • model ('botorch.models.model.Model') – A GP model

  • X_test (MatrixLike2d) – X matrix used for testing, must have the same dimension as X for training

  • return_type (Optional[str], optional) – either ‘tensor’ or ‘np’ by default ‘tensor’

  • negate_Y (Optional[bool], optional) – if true, negate the model predicted values in the case of minimization by default False

Returns

  • Y_test (MatrixLike2d) – Standardized prediction, the mean of postierior

  • Y_test_lower (MatrixLike2d) – The lower confidence interval

  • Y_test_upper (MatrixLike2d) – The upper confidence interval

Raises
nextorch.bo.model_predict_real(model: botorch.models.model.Model, X_test: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_mean: Union[list, nextorch.utils.Matrix, torch.Tensor], Y_std: Union[list, nextorch.utils.Matrix, torch.Tensor], return_type: Optional[str] = 'tensor', negate_Y: Optional[bool] = False) Tuple[Union[list, nextorch.utils.Matrix, torch.Tensor], Union[list, nextorch.utils.Matrix, torch.Tensor], Union[list, nextorch.utils.Matrix, torch.Tensor]]

Make predictions in real scale and returns numpy array

Parameters
  • model ('botorch.models.model.Model'_) – A GP model

  • X_test (MatrixLike2d) – X matrix used for testing, must have the same dimension as X for training

  • Y_mean (MatrixLike2d) – The mean of initial Y set

  • Y_std (MatrixLike2d) – The std of initial Y set

  • return_type (Optional[str], optional) – either ‘tensor’ or ‘np’ by default ‘tensor’

  • negate_Y (Optional[bool], optional) – if true, negate the model predicted values in the case of minimization by default False

Returns

  • Y_test_real (numpy matrix) – predictions in a real scale

  • Y_test_lower_real (numpy matrix) – The lower confidence interval in a real scale

  • Y_test_upper_real (numpy matrix) – The upper confidence interval in a real scale

  • _’botorch.models.model.Model’: https://botorch.org/api/models.html#botorch.models.model.Model