pub struct Optimizer<KInit, K, P, M> { /* private fields */ }Expand description
✨ Hyperparameter optimizer.
§Generic parameters
- [
KInit]: kernel type of the initial (prior) estimator component - [
K]: kernel type of the trials, it may (and will likely) be different from the prior component - [
P]: type of parameter that is optimized - [
M]: value of the target function, the less – the better
Implementations§
source§impl<KFirst, K, P, M> Optimizer<KFirst, K, P, M>
impl<KFirst, K, P, M> Optimizer<KFirst, K, P, M>
sourcepub const fn new(
min: P,
max: P,
init_component: Component<KFirst, P>,
kernel: K
) -> Self
pub const fn new( min: P, max: P, init_component: Component<KFirst, P>, kernel: K ) -> Self
Construct the new optimizer.
Here begins your adventure!
§Parameters
minandmax: parameter range, bounds are includedinit_component: your prior belief about which values of the searched parameter is more optimalkernel: kernel for the trial components
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<D>(&self, rng: &mut Rng) -> Pwhere
KFirst: Copy + Density<P, D> + Sample<P>,
K: Copy + Density<P, D> + Sample<P>,
P: Add<Output = P> + Copy + Debug + Div<Output = P> + Mul<Output = P> + Ord + Sub<Output = P> + UnsafeInto<D>,
D: Add<Output = D> + Copy + Debug + Div<Output = D> + Mul<Output = D> + Ord + UnsafeFromPrimitive<usize> + Zero,
pub fn new_trial<D>(&self, rng: &mut Rng) -> Pwhere
KFirst: Copy + Density<P, D> + Sample<P>,
K: Copy + Density<P, D> + Sample<P>,
P: Add<Output = P> + Copy + Debug + Div<Output = P> + Mul<Output = P> + Ord + Sub<Output = P> + UnsafeInto<D>,
D: Add<Output = D> + Copy + Debug + Div<Output = D> + Mul<Output = D> + Ord + UnsafeFromPrimitive<usize> + Zero,
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
- [
D]: kernel 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, K, P, M> Freeze for Optimizer<KInit, K, P, M>
impl<KInit, K, P, M> RefUnwindSafe for Optimizer<KInit, K, P, M>
impl<KInit, K, P, M> Send for Optimizer<KInit, K, P, M>
impl<KInit, K, P, M> Sync for Optimizer<KInit, K, P, M>
impl<KInit, K, P, M> Unpin for Optimizer<KInit, K, P, M>
impl<KInit, K, P, M> UnwindSafe for Optimizer<KInit, K, 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