pub struct Optimizer<KInit, P, M> { /* private fields */ }Expand description
✨ Hyperparameter optimizer.
§Generic parameters
- [
KInit]: kernel type of the initial (prior) estimator component - [
P]: type of parameter that is optimized - [
M]: value of the target function, the less – the better
Implementations§
source§impl<KInit, P, M> Optimizer<KInit, P, M>
impl<KInit, P, M> Optimizer<KInit, P, M>
sourcepub const fn new(range: RangeInclusive<P>, init_kernel: KInit, rng: Rng) -> Self
pub const fn new(range: RangeInclusive<P>, init_kernel: KInit, rng: Rng) -> Self
sourcepub const fn n_candidates(self, n_candidates: usize) -> Self
pub const fn n_candidates(self, n_candidates: usize) -> Self
sourcepub fn feed_back(&mut self, parameter: P, metric: M)
pub fn feed_back(&mut self, parameter: P, metric: M)
Provide the information about the trial, or in other words, «fit» the optimizer on the sample.
Normally, you’ll call your target function on parameters supplied by Optimizer::new_trial,
and feed back the results. But you also can feed it with any arbitrary parameters.
§Parameters
parameter: the target function parametermetric: the target function metric
sourcepub fn new_trial<K>(&mut self) -> P
pub fn new_trial<K>(&mut self) -> P
Generate a parameter value for a new trial.
After evaluating the target function with this parameter,
you’d better feed the metric back with Optimizer::feed_back.
§Type parameters
- [
K]: kernel type - [
D]: kernel density type
§Panics
This method may panic if a random or calculated number cannot be converted to the parameter or density type.
sourcepub fn best_trial(&self) -> Option<&Trial<P, M>>
pub fn best_trial(&self) -> Option<&Trial<P, M>>
Get the best trial.
Trait Implementations§
Auto Trait Implementations§
impl<KInit, P, M> Freeze for Optimizer<KInit, P, M>
impl<KInit, P, M> RefUnwindSafe for Optimizer<KInit, P, M>
impl<KInit, P, M> Send for Optimizer<KInit, P, M>
impl<KInit, P, M> Sync for Optimizer<KInit, P, M>
impl<KInit, P, M> Unpin for Optimizer<KInit, P, M>
impl<KInit, P, M> UnwindSafe for Optimizer<KInit, P, M>
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