pub struct ModelTreeNode {
pub feature: Option<usize>,
pub threshold: Float,
pub left: Option<Box<ModelTreeNode>>,
pub right: Option<Box<ModelTreeNode>>,
pub coefficients: Option<Array1<Float>>,
pub intercept: Option<Float>,
pub n_samples: usize,
pub std_dev: Float,
}Expand description
Node in a Model Tree
Fields§
§feature: Option<usize>Feature index for splitting (None for leaf nodes)
threshold: FloatSplit threshold value
left: Option<Box<ModelTreeNode>>Left child node (samples <= threshold)
right: Option<Box<ModelTreeNode>>Right child node (samples > threshold)
coefficients: Option<Array1<Float>>Linear model coefficients for leaf node
intercept: Option<Float>Intercept for linear model in leaf
n_samples: usizeNumber of samples in this node
std_dev: FloatStandard deviation of targets in this node
Implementations§
Source§impl ModelTreeNode
impl ModelTreeNode
Sourcepub fn new_leaf(
coefficients: Array1<Float>,
intercept: Float,
n_samples: usize,
std_dev: Float,
) -> Self
pub fn new_leaf( coefficients: Array1<Float>, intercept: Float, n_samples: usize, std_dev: Float, ) -> Self
Create a new leaf node with a linear model
Sourcepub fn new_internal(
feature: usize,
threshold: Float,
left: Self,
right: Self,
n_samples: usize,
std_dev: Float,
) -> Self
pub fn new_internal( feature: usize, threshold: Float, left: Self, right: Self, n_samples: usize, std_dev: Float, ) -> Self
Create a new internal split node
Sourcepub fn predict_sample(&self, sample: &ArrayView1<'_, Float>) -> Float
pub fn predict_sample(&self, sample: &ArrayView1<'_, Float>) -> Float
Predict value for a single sample
Trait Implementations§
Source§impl Clone for ModelTreeNode
impl Clone for ModelTreeNode
Source§fn clone(&self) -> ModelTreeNode
fn clone(&self) -> ModelTreeNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelTreeNode
impl RefUnwindSafe for ModelTreeNode
impl Send for ModelTreeNode
impl Sync for ModelTreeNode
impl Unpin for ModelTreeNode
impl UnwindSafe for ModelTreeNode
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