AutoTuner

Struct AutoTuner 

Source
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>,

Source

pub fn new(strategy: S) -> Self

Create new tuner with search strategy.

Source

pub fn time_limit_secs(self, secs: u64) -> Self

Add time limit in seconds.

Source

pub fn time_limit_mins(self, mins: u64) -> Self

Add time limit in minutes.

Source

pub fn early_stopping(self, patience: usize) -> Self

Add early stopping with patience.

Source

pub fn verbose(self) -> Self

Add verbose progress logging.

Source

pub fn callback(self, cb: impl Callback<P> + 'static) -> Self

Add custom callback.

Source

pub fn maximize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
where F: FnMut(&Trial<P>) -> f64,

Run optimization to maximize objective.

Source

pub fn minimize<F>(self, space: &SearchSpace<P>, objective: F) -> TuneResult<P>
where F: FnMut(&Trial<P>) -> f64,

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>
where S: Unpin, P: Unpin,

§

impl<S, P> !UnwindSafe for AutoTuner<S, P>

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