pub struct AdaBoostParams<P, R>(/* private fields */);Expand description
A helper struct for building AdaBoost hyperparameters.
This struct follows the builder pattern, allowing you to chain method calls to configure the AdaBoost algorithm before fitting.
§Example
use linfa_ensemble::AdaBoostParams;
use linfa_trees::DecisionTree;
let params = AdaBoostParams::new(DecisionTree::<f64, usize>::params().max_depth(Some(1)))
.n_estimators(100)
.learning_rate(0.5);Implementations§
Source§impl<P> AdaBoostParams<P, ThreadRng>
impl<P> AdaBoostParams<P, ThreadRng>
Source§impl<P, R: Rng + Clone> AdaBoostParams<P, R>
impl<P, R: Rng + Clone> AdaBoostParams<P, R>
Sourcepub fn new_fixed_rng(model_params: P, rng: R) -> AdaBoostParams<P, R>
pub fn new_fixed_rng(model_params: P, rng: R) -> AdaBoostParams<P, R>
Create a new AdaBoost parameter set with a fixed RNG for reproducibility.
§Arguments
model_params- The parameters for the base learnerrng- A seeded random number generator for reproducible results
§Example
use linfa_ensemble::AdaBoostParams;
use linfa_trees::DecisionTree;
use ndarray_rand::rand::SeedableRng;
use rand::rngs::SmallRng;
let rng = SmallRng::seed_from_u64(42);
let params = AdaBoostParams::new_fixed_rng(
DecisionTree::<f64, usize>::params().max_depth(Some(1)),
rng
);Sourcepub fn n_estimators(self, n_estimators: usize) -> Self
pub fn n_estimators(self, n_estimators: usize) -> Self
Sourcepub fn learning_rate(self, learning_rate: f64) -> Self
pub fn learning_rate(self, learning_rate: f64) -> Self
Set the learning rate (shrinkage parameter).
§Arguments
learning_rate- Must be positive. Typical values: 0.01 to 2.0
§Notes
- Values < 1.0 provide regularization and often improve generalization
- Lower values require more estimators to achieve similar performance
- A common strategy is to use learning_rate=0.1 with n_estimators=500
Trait Implementations§
Source§impl<P: Clone, R: Clone> Clone for AdaBoostParams<P, R>
impl<P: Clone, R: Clone> Clone for AdaBoostParams<P, R>
Source§fn clone(&self) -> AdaBoostParams<P, R>
fn clone(&self) -> AdaBoostParams<P, R>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<P: Copy, R: Copy> Copy for AdaBoostParams<P, R>
Source§impl<P, R> ParamGuard for AdaBoostParams<P, R>
impl<P, R> ParamGuard for AdaBoostParams<P, R>
Source§type Checked = AdaBoostValidParams<P, R>
type Checked = AdaBoostValidParams<P, R>
The checked hyperparameters
Source§fn check_ref(&self) -> Result<&Self::Checked>
fn check_ref(&self) -> Result<&Self::Checked>
Checks the hyperparameters and returns a reference to the checked hyperparameters if
successful
Source§fn check(self) -> Result<Self::Checked>
fn check(self) -> Result<Self::Checked>
Checks the hyperparameters and returns the checked hyperparameters if successful
Source§fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
Calls
check() and unwraps the resultSource§impl<P: PartialEq, R: PartialEq> PartialEq for AdaBoostParams<P, R>
impl<P: PartialEq, R: PartialEq> PartialEq for AdaBoostParams<P, R>
Source§fn eq(&self, other: &AdaBoostParams<P, R>) -> bool
fn eq(&self, other: &AdaBoostParams<P, R>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<P, R> StructuralPartialEq for AdaBoostParams<P, R>
Auto Trait Implementations§
impl<P, R> Freeze for AdaBoostParams<P, R>
impl<P, R> RefUnwindSafe for AdaBoostParams<P, R>where
P: RefUnwindSafe,
R: RefUnwindSafe,
impl<P, R> Send for AdaBoostParams<P, R>
impl<P, R> Sync for AdaBoostParams<P, R>
impl<P, R> Unpin for AdaBoostParams<P, R>
impl<P, R> UnsafeUnpin for AdaBoostParams<P, R>where
P: UnsafeUnpin,
R: UnsafeUnpin,
impl<P, R> UnwindSafe for AdaBoostParams<P, R>where
P: UnwindSafe,
R: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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