Skip to main content

BayesianOptimization

Struct BayesianOptimization 

Source
pub struct BayesianOptimization { /* private fields */ }
Expand description

Bayesian Optimization for hyperparameter tuning.

Uses Gaussian Processes to model the objective function and acquisition functions to intelligently select the next hyperparameters to evaluate.

§Algorithm

  1. Initialize with random samples
  2. Fit Gaussian Process to observed data
  3. Optimize acquisition function to find next point
  4. Evaluate objective at new point
  5. Repeat steps 2-4 until budget exhausted

§Example

use tensorlogic_train::*;
use std::collections::HashMap;

let mut param_space = HashMap::new();
param_space.insert(
    "lr".to_string(),
    HyperparamSpace::log_uniform(1e-4, 1e-1).unwrap(),
);

let mut bayes_opt = BayesianOptimization::new(
    param_space,
    10,  // n_iterations
    5,   // n_initial_points
    42,  // seed
);

// In practice, you would evaluate your model here
// bayes_opt.add_result(result);

Implementations§

Source§

impl BayesianOptimization

Source

pub fn new( param_space: HashMap<String, HyperparamSpace>, n_iterations: usize, n_initial_points: usize, seed: u64, ) -> Self

Create a new Bayesian Optimization instance.

§Arguments
  • param_space - Hyperparameter space definition
  • n_iterations - Number of optimization iterations
  • n_initial_points - Number of random initialization points
  • seed - Random seed for reproducibility
Source

pub fn with_acquisition(self, acquisition_fn: AcquisitionFunction) -> Self

Set acquisition function.

Source

pub fn with_kernel(self, kernel: GpKernel) -> Self

Set kernel.

Source

pub fn with_noise(self, noise_variance: f64) -> Self

Set noise variance.

Source

pub fn suggest(&mut self) -> TrainResult<HyperparamConfig>

Suggest next hyperparameter configuration to evaluate.

Source

pub fn add_result(&mut self, result: HyperparamResult)

Add a result from evaluating a configuration.

Source

pub fn best_result(&self) -> Option<&HyperparamResult>

Get the best result found so far.

Source

pub fn sorted_results(&self) -> Vec<&HyperparamResult>

Get all results sorted by score (descending).

Source

pub fn results(&self) -> &[HyperparamResult]

Get all results.

Source

pub fn is_complete(&self) -> bool

Check if optimization is complete.

Source

pub fn current_iteration(&self) -> usize

Get current iteration number.

Source

pub fn total_budget(&self) -> usize

Get total budget (initial + iterations).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V