Developer API for surrogate models

class smt.surrogate_models.surrogate_model.SurrogateModel(**kwargs)[source]

Base class for all surrogate models.

Attributes:
optionsOptionsDictionary

Dictionary of options. Options values can be set on this attribute directly or they can be passed in as keyword arguments during instantiation.

supportsdict

Dictionary containing information about what this surrogate model supports.

Methods

load(filename)

Static method implemented by each surrogate model type (ie class) to load the surrogate object from a file created by using the corresponding save method

predict_derivatives(x, kx)

Predict the dy_dx derivatives at a set of points.

predict_output_derivatives(x)

Predict the derivatives dy_dyt at a set of points.

predict_values(x)

Predict the output values at a set of points.

predict_variance_derivatives(x, kx)

Provide the derivatives of the variance of the model at a set of points.

predict_variance_gradient(x)

Provide the gradient of the variance of the model at a given point (ie the derivatives wrt to all component at a unique point x)

predict_variances(x)

Predict the variances at a set of points.

save(filename)

Implemented by surrogate models to save the surrogate object in a file

set_training_derivatives(xt, dyt_dxt, kx[, name])

Set training data (derivatives).

set_training_values(xt, yt[, name])

Set training data (values).

train()

Train the model

update_training_derivatives(dyt_dxt, kx[, name])

Update the training data (values) at the previously set input values.

update_training_values(yt[, name])

Update the training data (values) at the previously set input values.

Examples

>>> from smt.surrogate_models import RBF
>>> sm = RBF(print_training=False)
>>> sm.options['print_prediction'] = False
_initialize()[source]

Implemented by surrogate models to declare options and declare what they support (optional).

Examples

self.options.declare(‘option_name’, default_value, types=(bool, int), desc=’description’) self.supports[‘derivatives’] = True

_train() None[source]

Implemented by surrogate models to perform training (optional, but typically implemented).

abstract _predict_values(x: ndarray) ndarray[source]

Implemented by surrogate models to predict the output values.

Parameters:
xnp.ndarray[nt, nx]

Input values for the prediction points.

Returns:
ynp.ndarray[nt, ny]

Output values at the prediction points.

_predict_derivatives(x: ndarray, kx: int) ndarray[source]

Implemented by surrogate models to predict the dy_dx derivatives (optional).

If this method is implemented, the surrogate model should have self.supports[‘derivatives’] = True in the _initialize() implementation.

Parameters:
xnp.ndarray[nt, nx]

Input values for the prediction points.

kxint

The 0-based index of the input variable with respect to which derivatives are desired.

Returns:
dy_dxnp.ndarray[nt, ny]

Derivatives.

_predict_output_derivatives(x: ndarray) dict[source]

Implemented by surrogate models to predict the dy_dyt derivatives (optional).

If this method is implemented, the surrogate model should have self.supports[‘derivatives’] = True in the _initialize() implementation.

Parameters:
xnp.ndarray[nt, nx]

Input values for the prediction points.

Returns:
dy_dytdict of np.ndarray[nt, nt]

Dictionary of output derivatives. Key is None for derivatives wrt yt and kx for derivatives wrt dyt_dxt.

_predict_variances(x: ndarray) ndarray[source]

Implemented by surrogate models to predict the variances at a set of points (optional).

If this method is implemented, the surrogate model should have self.supports[‘variances’] = True in the _initialize() implementation.

Parameters:
xnp.ndarray[nt, nx]

Input values for the prediction points.

is_actingnp.ndarray[nt, nx] or np.ndarray[nt]

Matrix specifying for each design variable whether it is acting or not (for hierarchical design spaces)

Returns:
s2np.ndarray[nt, ny]

Variances.