pub struct RandomForestRegressor { /* private fields */ }Expand description
Random forest regressor (squared-error CART trees on bootstrap samples).
Defaults match scikit-learn’s RandomForestRegressor: 100 trees, all
features per split, unlimited depth, min_samples_leaf = 1.
use dml_core::{MaxFeatures, RandomForestRegressor};
let rf = RandomForestRegressor::new()
.n_estimators(200)
.min_samples_leaf(5)
.max_features(MaxFeatures::Fraction(0.5))
.seed(42);Implementations§
Source§impl RandomForestRegressor
impl RandomForestRegressor
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 Clone for RandomForestRegressor
impl Clone for RandomForestRegressor
Source§impl Debug for RandomForestRegressor
impl Debug for RandomForestRegressor
Source§impl Default for RandomForestRegressor
impl Default for RandomForestRegressor
Source§impl Regressor for RandomForestRegressor
impl Regressor for RandomForestRegressor
fn fit(&mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>) -> Result<()>
Source§fn fit_weighted(
&mut self,
x: ArrayView2<'_, f64>,
y: ArrayView1<'_, f64>,
w: ArrayView1<'_, f64>,
) -> Result<()>
fn fit_weighted( &mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>, w: ArrayView1<'_, f64>, ) -> Result<()>
Fit minimising a
w-weighted loss (needed by the RLearner).
The default reports that weights are unsupported.fn predict(&self, x: ArrayView2<'_, f64>) -> Result<Array1<f64>>
fn fresh(&self) -> Box<dyn Regressor>
Auto Trait Implementations§
impl Freeze for RandomForestRegressor
impl RefUnwindSafe for RandomForestRegressor
impl Send for RandomForestRegressor
impl Sync for RandomForestRegressor
impl Unpin for RandomForestRegressor
impl UnsafeUnpin for RandomForestRegressor
impl UnwindSafe for RandomForestRegressor
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