pub struct BayesianOptimizer { /* private fields */ }Expand description
let kernel = RBF::new(1.0); let gpr = GaussianProcessRegressor::new().kernel(Box::new(kernel)); let optimizer = BayesianOptimizer::new(gpr) .acquisition(AcquisitionFunction::ExpectedImprovement) .xi(0.01);
// Define bounds and initial points let bounds = array![[0.0, 10.0]]; // 1D optimization between 0 and 10 let X_init = array![[1.0], [5.0], [9.0]]; let y_init = array![1.0, 25.0, 81.0]; // f(x) = x^2
let mut bo = optimizer.fit_initial(&X_init.view(), &y_init.view()).unwrap(); let next_point = bo.suggest_next_point(&bounds.view()).unwrap();
Implementations§
Source§impl BayesianOptimizer
impl BayesianOptimizer
Sourcepub fn new(_gp: GaussianProcessRegressor) -> Self
pub fn new(_gp: GaussianProcessRegressor) -> Self
Create a new BayesianOptimizer instance
Sourcepub fn acquisition(self, acquisition: AcquisitionFunction) -> Self
pub fn acquisition(self, acquisition: AcquisitionFunction) -> Self
Set the acquisition function
Sourcepub fn n_restarts(self, n_restarts: usize) -> Self
pub fn n_restarts(self, n_restarts: usize) -> Self
Set the number of random restarts for acquisition optimization
Sourcepub fn random_state(self, random_state: Option<u64>) -> Self
pub fn random_state(self, random_state: Option<u64>) -> Self
Set the random state
Sourcepub fn builder() -> BayesianOptimizerBuilder
pub fn builder() -> BayesianOptimizerBuilder
Create a builder for the Bayesian optimizer
Sourcepub fn fit_initial(
self,
X: &ArrayView2<'_, f64>,
y: &ArrayView1<'_, f64>,
) -> SklResult<BayesianOptimizerFitted>
pub fn fit_initial( self, X: &ArrayView2<'_, f64>, y: &ArrayView1<'_, f64>, ) -> SklResult<BayesianOptimizerFitted>
Fit the initial Gaussian Process model
Trait Implementations§
Source§impl Clone for BayesianOptimizer
impl Clone for BayesianOptimizer
Source§fn clone(&self) -> BayesianOptimizer
fn clone(&self) -> BayesianOptimizer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BayesianOptimizer
impl !RefUnwindSafe for BayesianOptimizer
impl Send for BayesianOptimizer
impl Sync for BayesianOptimizer
impl Unpin for BayesianOptimizer
impl !UnwindSafe for BayesianOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more