pub struct RandomForestClassifier { /* private fields */ }Expand description
Random forest classifier for 0/1 labels; predict_proba averages the
class-1 frequency of the leaves.
Defaults match scikit-learn’s RandomForestClassifier: 100 trees,
√p features per split, unlimited depth, min_samples_leaf = 1.
Implementations§
Source§impl RandomForestClassifier
impl RandomForestClassifier
pub fn new() -> Self
Sourcepub fn n_estimators(self, n: usize) -> Self
pub fn n_estimators(self, n: usize) -> Self
Number of trees (default 100).
Sourcepub fn min_samples_split(self, n: usize) -> Self
pub fn min_samples_split(self, n: usize) -> Self
Minimum number of rows required to split a node (default 2).
Sourcepub fn min_samples_leaf(self, n: usize) -> Self
pub fn min_samples_leaf(self, n: usize) -> Self
Minimum number of distinct rows in each leaf (default 1). Values around 5–20 give smoother nuisance estimates for DML.
Sourcepub fn max_features(self, m: MaxFeatures) -> Self
pub fn max_features(self, m: MaxFeatures) -> Self
Features considered per split.
Sourcepub fn bootstrap(self, bootstrap: bool) -> Self
pub fn bootstrap(self, bootstrap: bool) -> Self
Grow each tree on a bootstrap sample (default true).
Sourcepub fn max_samples(self, fraction: Option<f64>) -> Self
pub fn max_samples(self, fraction: Option<f64>) -> Self
Bootstrap sample size as a fraction of n (default 1.0).
Sourcepub fn seed(self, seed: u64) -> Self
pub fn seed(self, seed: u64) -> Self
Seed for bootstrap draws and feature sampling (default 0).
Sourcepub fn feature_importances(&self) -> Option<&Array1<f64>>
pub fn feature_importances(&self) -> Option<&Array1<f64>>
Mean decrease in impurity per feature (sums to one), after fitting.
Trait Implementations§
Source§impl Classifier for RandomForestClassifier
impl Classifier for RandomForestClassifier
fn fit(&mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>) -> Result<()>
fn predict_proba(&self, x: ArrayView2<'_, f64>) -> Result<Array1<f64>>
fn fresh(&self) -> Box<dyn Classifier>
Source§impl Clone for RandomForestClassifier
impl Clone for RandomForestClassifier
Source§impl Debug for RandomForestClassifier
impl Debug for RandomForestClassifier
Auto Trait Implementations§
impl Freeze for RandomForestClassifier
impl RefUnwindSafe for RandomForestClassifier
impl Send for RandomForestClassifier
impl Sync for RandomForestClassifier
impl Unpin for RandomForestClassifier
impl UnsafeUnpin for RandomForestClassifier
impl UnwindSafe for RandomForestClassifier
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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