pub struct BayesianSampler { /* private fields */ }Expand description
Bayesian optimization sampler using Tree-Parzen Estimator (TPE).
For the first n_startup trials, samples randomly. After that,
uses the history of (params, metric) to model “good” vs “bad”
parameter distributions and samples from the “good” distribution.
This is a simplified TPE: it splits trials into top/bottom quantiles and samples from the top quantile’s parameter distributions.
Implementations§
Trait Implementations§
Source§impl Sampler for BayesianSampler
impl Sampler for BayesianSampler
Source§fn record_result(&mut self, params: &HashMap<String, Value>, value: f64)
fn record_result(&mut self, params: &HashMap<String, Value>, value: f64)
Completed-trial feedback — this is what makes TPE model-based instead of degenerating to random search.
Source§fn sample(
&mut self,
space: &SearchSpace,
trial_index: usize,
) -> Result<Option<HashMap<String, Value>>>
fn sample( &mut self, space: &SearchSpace, trial_index: usize, ) -> Result<Option<HashMap<String, Value>>>
Sample the next set of parameters. Returns None when exhausted.
Source§fn n_trials(&self) -> Option<usize>
fn n_trials(&self) -> Option<usize>
Total number of trials this sampler will produce (if known).
Source§fn prepare(&mut self, _space: &SearchSpace)
fn prepare(&mut self, _space: &SearchSpace)
Called once before the trial loop with the resolved search
space. Lets samplers precompute state — e.g.
GridSampler
resolves its dimension grid here so n_trials is correct
before the first sample.Auto Trait Implementations§
impl Freeze for BayesianSampler
impl RefUnwindSafe for BayesianSampler
impl Send for BayesianSampler
impl Sync for BayesianSampler
impl Unpin for BayesianSampler
impl UnsafeUnpin for BayesianSampler
impl UnwindSafe for BayesianSampler
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
Mutably borrows from an owned value. Read more