Skip to main content

SurrogateModel

Trait SurrogateModel 

Source
pub trait SurrogateModel {
    // Required methods
    fn fit(&mut self, x: &Array2<f64>, y: &Array1<f64>) -> OptimizeResult<()>;
    fn predict(&self, x: &Array1<f64>) -> OptimizeResult<f64>;
    fn predict_with_uncertainty(
        &self,
        x: &Array1<f64>,
    ) -> OptimizeResult<(f64, f64)>;
    fn n_samples(&self) -> usize;
    fn n_features(&self) -> usize;
    fn update(&mut self, x: &Array1<f64>, y: f64) -> OptimizeResult<()>;

    // Provided method
    fn predict_batch(&self, x: &Array2<f64>) -> OptimizeResult<Array1<f64>> { ... }
}
Expand description

Common trait for surrogate models

Required Methods§

Source

fn fit(&mut self, x: &Array2<f64>, y: &Array1<f64>) -> OptimizeResult<()>

Fit the surrogate model to the provided data

§Arguments
  • x - Training points, shape (n_samples, n_features)
  • y - Function values at training points, shape (n_samples,)
Source

fn predict(&self, x: &Array1<f64>) -> OptimizeResult<f64>

Predict the function value at a new point

§Arguments
  • x - Point to predict at, shape (n_features,)
§Returns

Predicted function value

Source

fn predict_with_uncertainty( &self, x: &Array1<f64>, ) -> OptimizeResult<(f64, f64)>

Predict the function value and uncertainty at a new point

§Arguments
  • x - Point to predict at, shape (n_features,)
§Returns

(predicted mean, predicted standard deviation)

Source

fn n_samples(&self) -> usize

Get the number of training points

Source

fn n_features(&self) -> usize

Get the dimensionality of the problem

Source

fn update(&mut self, x: &Array1<f64>, y: f64) -> OptimizeResult<()>

Add a new data point and update the model

Provided Methods§

Source

fn predict_batch(&self, x: &Array2<f64>) -> OptimizeResult<Array1<f64>>

Predict at multiple points

§Arguments
  • x - Points to predict at, shape (n_points, n_features)
§Returns

Predicted values, shape (n_points,)

Implementors§