cosapp.utils.surrogate_models.nearest_neighbor

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

https://github.com/SMarone/NDInterp

Classes

LinearNearestNeighbor(**options)

Surrogate model that approximates values using a linear interpolator.

NearestNeighbor([interpolant_type])

Surrogate model that approximates values using a nearest neighbor approximation.

RBFNearestNeighbor(**options)

Surrogate model that approximates values using a RBF interpolator.

WeightedNearestNeighbor(**options)

Surrogate model that approximates values using a weighted interpolator.

class cosapp.utils.surrogate_models.nearest_neighbor.LinearNearestNeighbor(**options)[source]

Bases: NearestNeighbor

Surrogate model that approximates values using a linear interpolator.

interpolant

Interpolator object

Type:

object

options

Input keyword arguments for the interpolator.

Type:

dict

interpolant_type

Type of interpolator; here LinearInterpolator

Type:

Type[NNBase]

class cosapp.utils.surrogate_models.nearest_neighbor.NearestNeighbor(interpolant_type='rbf', **options)[source]

Bases: SurrogateModel

Surrogate model that approximates values using a nearest neighbor approximation.

interpolant

Interpolator object

Type:

object

options

Input keyword arguments for the interpolator.

Type:

dict

interpolant_type

Type of interpolator from NearestNeighbor.interpolators()

Type:

NNBase

static interpolators() Dict[str, Type[SurrogateModel]][source]
linearize(x, **kwargs)[source]

Calculate the jacobian of the interpolant at the requested point.

Parameters:
  • x (array-like) – Point at which the surrogate Jacobian is evaluated.

  • **kwargs (dict) – Additional keyword arguments passed to the interpolant.

Returns:

Jacobian of surrogate output wrt inputs.

Return type:

ndarray

predict(x, **kwargs)[source]

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

Parameters:
  • x (array-like) – Point(s) at which the surrogate is evaluated.

  • **kwargs (dict) – Additional keyword arguments passed to the interpolant.

Returns:

Predicted value.

Return type:

float

train(x, y)[source]

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

Parameters:
  • x (array-like) – Training input locations

  • y (array-like) – Model responses at given inputs.

class cosapp.utils.surrogate_models.nearest_neighbor.RBFNearestNeighbor(**options)[source]

Bases: NearestNeighbor

Surrogate model that approximates values using a RBF interpolator.

interpolant

Interpolator object

Type:

object

options

Input keyword arguments for the interpolator.

Type:

dict

interpolant_type

Type of interpolator; here RBFInterpolator

Type:

Type[NNBase]

class cosapp.utils.surrogate_models.nearest_neighbor.WeightedNearestNeighbor(**options)[source]

Bases: NearestNeighbor

Surrogate model that approximates values using a weighted interpolator.

interpolant

Interpolator object

Type:

object

options

Input keyword arguments for the interpolator.

Type:

dict

interpolant_type

Type of interpolator; here WeightedInterpolator

Type:

Type[NNBase]