pub struct HoeffdingTreeClassifier { /* private fields */ }alloc only.Expand description
A streaming decision tree classifier based on the VFDT algorithm.
Grows incrementally by maintaining per-leaf class distributions and histogram bins. Splits are committed when the Hoeffding bound guarantees the best information-gain split is statistically superior to the runner-up.
§Thread Safety
HoeffdingTreeClassifier is Send + Sync, making it usable in async
and multi-threaded pipelines.
Implementations§
Source§impl HoeffdingTreeClassifier
impl HoeffdingTreeClassifier
Sourcepub fn new(config: HoeffdingClassifierConfig) -> Self
pub fn new(config: HoeffdingClassifierConfig) -> Self
Create a new classifier from the given configuration.
If config.n_features > 0, the tree is immediately initialized with a
root leaf. Otherwise, initialization is deferred until the first training
sample arrives.
Sourcepub fn train_one(&mut self, features: &[f64], class: usize)
pub fn train_one(&mut self, features: &[f64], class: usize)
Train on a single observation: route to leaf, update stats, maybe split.
§Arguments
features– feature vector for this observation.class– the class label (0-indexed).
Sourcepub fn predict_class(&self, features: &[f64]) -> usize
pub fn predict_class(&self, features: &[f64]) -> usize
Predict the majority class for the given feature vector.
Returns the class index with the highest count at the reached leaf. If no samples have been seen, returns 0.
Sourcepub fn predict_proba(&self, features: &[f64]) -> Vec<f64>
pub fn predict_proba(&self, features: &[f64]) -> Vec<f64>
Predict the class probability distribution for the given feature vector.
Returns a Vec<f64> of length n_classes where each entry is the
estimated probability (fraction of samples) for that class. The
probabilities sum to 1.0 (or all zeros if no samples seen).
Sourcepub fn max_depth_seen(&self) -> usize
pub fn max_depth_seen(&self) -> usize
Maximum depth reached by any node in the tree.
Sourcepub fn n_samples_seen(&self) -> u64
pub fn n_samples_seen(&self) -> u64
Total number of training samples seen since creation or last reset.
Trait Implementations§
Source§impl Clone for HoeffdingTreeClassifier
impl Clone for HoeffdingTreeClassifier
Source§fn clone(&self) -> HoeffdingTreeClassifier
fn clone(&self) -> HoeffdingTreeClassifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HoeffdingTreeClassifier
impl Debug for HoeffdingTreeClassifier
Source§impl StreamingLearner for HoeffdingTreeClassifier
impl StreamingLearner for HoeffdingTreeClassifier
Source§fn train_one(&mut self, features: &[f64], target: f64, _weight: f64)
fn train_one(&mut self, features: &[f64], target: f64, _weight: f64)
Train on a single observation.
The target is cast to usize for the class label. Weight is currently
unused (all samples contribute equally).
Source§fn predict(&self, features: &[f64]) -> f64
fn predict(&self, features: &[f64]) -> f64
Predict the majority class as a floating-point value.
Source§fn n_samples_seen(&self) -> u64
fn n_samples_seen(&self) -> u64
Source§fn train(&mut self, features: &[f64], target: f64)
fn train(&mut self, features: &[f64], target: f64)
Auto Trait Implementations§
impl Freeze for HoeffdingTreeClassifier
impl RefUnwindSafe for HoeffdingTreeClassifier
impl Send for HoeffdingTreeClassifier
impl Sync for HoeffdingTreeClassifier
impl Unpin for HoeffdingTreeClassifier
impl UnsafeUnpin for HoeffdingTreeClassifier
impl UnwindSafe for HoeffdingTreeClassifier
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
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>
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>
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