nearest_neighbor.py#

Surrogate model based on the N-Dimensional Interpolation library by Stephen Marone.

SMarone/NDInterp

class openmdao.surrogate_models.nearest_neighbor.NearestNeighbor(**kwargs)[source]

Bases: SurrogateModel

Surrogate model that approximates values using a nearest neighbor approximation.

Parameters:
**kwargsdict

Options dictionary.

Attributes:
interpolantobject

Interpolator object

interpolant_init_argsdict

Input keyword arguments for the interpolator.

__init__(**kwargs)[source]

Initialize all attributes.

Parameters:
**kwargsdict

options dictionary.

linearize(x, **kwargs)[source]

Calculate the jacobian of the interpolant at the requested point.

Parameters:
xarray-like

Point at which the surrogate Jacobian is evaluated.

**kwargsdict

Additional keyword arguments passed to the interpolant.

Returns:
ndarray

Jacobian of surrogate output wrt inputs.

predict(x, **kwargs)[source]

Calculate a predicted value of the response based on the current trained model.

Parameters:
xarray-like

Point(s) at which the surrogate is evaluated.

**kwargsdict

Additional keyword arguments passed to the interpolant.

Returns:
float

Predicted value.

train(x, y)[source]

Train the surrogate model with the given set of inputs and outputs.

Parameters:
xarray-like

Training input locations.

yarray-like

Model responses at given inputs.

vectorized_predict(x)

Calculate predicted values of the response based on the current trained model.

Parameters:
xarray-like

Vectorized point(s) at which the surrogate is evaluated.