SearchSpace

Struct SearchSpace 

Source
pub struct SearchSpace<P: ParamKey = GenericParam> { /* private fields */ }
Expand description

Type-safe search space for hyperparameters.

§Example

use aprender::automl::{SearchSpace, LogScale};
use aprender::automl::params::RandomForestParam as RF;

let space = SearchSpace::new()
    .add(RF::NEstimators, 10..500)
    .add(RF::MaxDepth, 2..20);

assert_eq!(space.len(), 2);

Implementations§

Source§

impl<P: ParamKey> SearchSpace<P>

Source

pub fn new() -> Self

Create an empty search space.

Source

pub fn len(&self) -> usize

Number of parameters in the space.

Source

pub fn is_empty(&self) -> bool

Check if space is empty.

Source

pub fn add(self, key: P, range: Range<i64>) -> Self

Add an integer parameter from a range.

Source

pub fn add_continuous(self, key: P, low: f64, high: f64) -> Self

Add a continuous parameter from a float range.

Source

pub fn add_log_scale(self, key: P, log_scale: LogScale) -> Self

Add a log-scale continuous parameter.

Source

pub fn add_categorical<I, V>(self, key: P, choices: I) -> Self
where I: IntoIterator<Item = V>, V: Into<ParamValue>,

Add a categorical parameter from string choices.

Source

pub fn add_bool(self, key: P, choices: [bool; 2]) -> Self

Add a boolean parameter.

Source

pub fn add_param(self, key: P, param: HyperParam) -> Self

Add a raw HyperParam.

Source

pub fn get(&self, key: &P) -> Option<&HyperParam>

Get parameter definition by key.

Source

pub fn iter(&self) -> impl Iterator<Item = (&P, &HyperParam)>

Iterate over parameter definitions.

Source

pub fn sample(&self, rng: &mut impl Rng) -> Trial<P>

Sample a random configuration.

Source

pub fn grid(&self, points_per_param: usize) -> Vec<Trial<P>>

Generate all grid configurations.

Trait Implementations§

Source§

impl<P: Clone + ParamKey> Clone for SearchSpace<P>

Source§

fn clone(&self) -> SearchSpace<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + ParamKey> Debug for SearchSpace<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: ParamKey> Default for SearchSpace<P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<P> Freeze for SearchSpace<P>

§

impl<P> RefUnwindSafe for SearchSpace<P>
where P: RefUnwindSafe,

§

impl<P> Send for SearchSpace<P>
where P: Send,

§

impl<P> Sync for SearchSpace<P>
where P: Sync,

§

impl<P> Unpin for SearchSpace<P>
where P: Unpin,

§

impl<P> UnwindSafe for SearchSpace<P>
where P: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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