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 · 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.