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>
impl<X, Y> HalvingGridSearch<X, Y>
Sourcepub fn new(param_distributions: ParameterDistributions) -> Self
pub fn new(param_distributions: ParameterDistributions) -> Self
Create a new HalvingGridSearch
Sourcepub fn n_candidates(self, n_candidates: usize) -> Self
pub fn n_candidates(self, n_candidates: usize) -> Self
Set the number of initial candidates
Sourcepub fn cv(self, cv: Box<dyn CrossValidator>) -> Self
pub fn cv(self, cv: Box<dyn CrossValidator>) -> Self
Set the cross-validation strategy
Sourcepub fn max_resource(self, max_resource: usize) -> Self
pub fn max_resource(self, max_resource: usize) -> Self
Set the maximum resource
Sourcepub fn min_resource(self, min_resource: usize) -> Self
pub fn min_resource(self, min_resource: usize) -> Self
Set the minimum resource
Sourcepub fn aggressive_elimination(self, aggressive: bool) -> Self
pub fn aggressive_elimination(self, aggressive: bool) -> Self
Enable or disable aggressive elimination
Sourcepub fn random_state(self, seed: u64) -> Self
pub fn random_state(self, seed: u64) -> Self
Set random state for reproducibility
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>
impl<X, Y> Sync for HalvingGridSearch<X, Y>
impl<X, Y> Unpin for HalvingGridSearch<X, Y>
impl<X, Y> !UnwindSafe for HalvingGridSearch<X, Y>
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