HalvingGridSearch

Struct HalvingGridSearch 

Source
pub struct HalvingGridSearch<X, Y> { /* private fields */ }
Expand description

HalvingGridSearch implementation

Uses successive halving to efficiently search hyperparameter spaces by progressively eliminating poor-performing candidates using increasing amounts of resources (typically training samples).

§Example

use sklears_model_selection::{HalvingGridSearch, KFold, ParameterDistribution};
use scirs2_core::ndarray::array;
///
let X = array![[1.0, 2.0], [2.0, 3.0], [3.0, 3.0], [2.0, 1.0]];
let y = array![1.5, 2.5, 3.0, 1.8];

// Create parameter distributions
let mut param_distributions = HashMap::new();
param_distributions.insert("fit_intercept".to_string(),
    ParameterDistribution::Choice(vec![true.into(), false.into()]));

let search: HalvingGridSearch<scirs2_core::ndarray::Array2`<f64>`, scirs2_core::ndarray::Array1`<f64>`> = HalvingGridSearch::new(param_distributions)
    .n_candidates(8)
    .factor(2.0)
    .cv(Box::new(KFold::new(3)))
    .random_state(42);

// let results = search.fit(LinearRegression::new(), &X, &y);

Implementations§

Source§

impl<X, Y> HalvingGridSearch<X, Y>

Source

pub fn new(param_distributions: ParameterDistributions) -> Self

Create a new HalvingGridSearch

Source

pub fn n_candidates(self, n_candidates: usize) -> Self

Set the number of initial candidates

Source

pub fn factor(self, factor: f64) -> Self

Set the reduction factor for successive halving

Source

pub fn cv(self, cv: Box<dyn CrossValidator>) -> Self

Set the cross-validation strategy

Source

pub fn scoring(self, scoring: Scoring) -> Self

Set the scoring function

Source

pub fn resource(self, resource: String) -> Self

Set the resource parameter

Source

pub fn max_resource(self, max_resource: usize) -> Self

Set the maximum resource

Source

pub fn min_resource(self, min_resource: usize) -> Self

Set the minimum resource

Source

pub fn aggressive_elimination(self, aggressive: bool) -> Self

Enable or disable aggressive elimination

Source

pub fn random_state(self, seed: u64) -> Self

Set random state for reproducibility

Source§

impl HalvingGridSearch<Array2<f64>, Array1<f64>>

Source

pub fn fit<E, F>( &self, base_estimator: E, x: &Array2<f64>, y: &Array1<f64>, ) -> Result<HalvingGridSearchResults>
where E: Estimator + Clone + Fit<Array2<f64>, Array1<f64>, Fitted = F>, F: Predict<Array2<f64>, Array1<f64>>,

Fit the halving grid search for regression

Source§

impl HalvingGridSearch<Array2<f64>, Array1<i32>>

Source

pub fn fit_classification<E, F>( &self, base_estimator: E, x: &Array2<f64>, y: &Array1<i32>, ) -> Result<HalvingGridSearchResults>
where E: Estimator + Clone + Fit<Array2<f64>, Array1<i32>, Fitted = F>, F: Predict<Array2<f64>, Array1<i32>>,

Fit the halving grid search for classification

Auto Trait Implementations§

§

impl<X, Y> Freeze for HalvingGridSearch<X, Y>

§

impl<X, Y> !RefUnwindSafe for HalvingGridSearch<X, Y>

§

impl<X, Y> Send for HalvingGridSearch<X, Y>
where X: Send, Y: Send,

§

impl<X, Y> Sync for HalvingGridSearch<X, Y>
where X: Sync, Y: Sync,

§

impl<X, Y> Unpin for HalvingGridSearch<X, Y>
where X: Unpin, Y: Unpin,

§

impl<X, Y> !UnwindSafe for HalvingGridSearch<X, Y>

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