pub struct AutoTuner<S, P: ParamKey> { /* private fields */ }Expand description
AutoTuner for hyperparameter optimization.
§Example
ⓘ
use aprender::automl::{AutoTuner, RandomSearch, SearchSpace};
use aprender::automl::params::RandomForestParam as RF;
let space = SearchSpace::new()
.add(RF::NEstimators, 10..500)
.add(RF::MaxDepth, 2..20);
let result = AutoTuner::new(RandomSearch::new(100))
.time_limit_secs(60)
.early_stopping(20)
.maximize(space, |trial| {
let n = trial.get_usize(&RF::NEstimators).unwrap_or(100);
let d = trial.get_usize(&RF::MaxDepth).unwrap_or(5);
// Return cross-validation score
evaluate_model(n, d)
});
println!("Best: {:?}", result.best_trial);Implementations§
Source§impl<S, P: ParamKey> AutoTuner<S, P>where
S: SearchStrategy<P>,
impl<S, P: ParamKey> AutoTuner<S, P>where
S: SearchStrategy<P>,
Sourcepub fn time_limit_secs(self, secs: u64) -> Self
pub fn time_limit_secs(self, secs: u64) -> Self
Add time limit in seconds.
Sourcepub fn time_limit_mins(self, mins: u64) -> Self
pub fn time_limit_mins(self, mins: u64) -> Self
Add time limit in minutes.
Sourcepub fn early_stopping(self, patience: usize) -> Self
pub fn early_stopping(self, patience: usize) -> Self
Add early stopping with patience.
Sourcepub fn maximize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
pub fn maximize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
Run optimization to maximize objective.
Sourcepub fn minimize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
pub fn minimize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
Run optimization to minimize objective.
Auto Trait Implementations§
impl<S, P> Freeze for AutoTuner<S, P>where
S: Freeze,
impl<S, P> !RefUnwindSafe for AutoTuner<S, P>
impl<S, P> !Send for AutoTuner<S, P>
impl<S, P> !Sync for AutoTuner<S, P>
impl<S, P> Unpin for AutoTuner<S, P>
impl<S, P> !UnwindSafe for AutoTuner<S, P>
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
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>
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 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>
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