Skip to main content

StreamingTree

Trait StreamingTree 

Source
pub trait StreamingTree: Send + Sync {
    // Required methods
    fn train_one(&mut self, features: &[f64], gradient: f64, hessian: f64);
    fn predict(&self, features: &[f64]) -> f64;
    fn n_leaves(&self) -> usize;
    fn n_samples_seen(&self) -> u64;
    fn reset(&mut self);

    // Provided methods
    fn split_gains(&self) -> &[f64] { ... }
    fn predict_with_variance(&self, features: &[f64]) -> (f64, f64) { ... }
}
Available on crate feature alloc only.
Expand description

A streaming decision tree that trains incrementally.

Required Methods§

Source

fn train_one(&mut self, features: &[f64], gradient: f64, hessian: f64)

Train on a single gradient/hessian pair at the given feature vector.

Source

fn predict(&self, features: &[f64]) -> f64

Predict the leaf value for a feature vector.

Source

fn n_leaves(&self) -> usize

Current number of leaf nodes.

Source

fn n_samples_seen(&self) -> u64

Total samples seen since creation.

Source

fn reset(&mut self)

Reset to initial state (single root leaf).

Provided Methods§

Source

fn split_gains(&self) -> &[f64]

Accumulated split gains per feature for importance tracking.

Returns an empty slice if the tree hasn’t seen any features yet or the implementation doesn’t track split gains.

Source

fn predict_with_variance(&self, features: &[f64]) -> (f64, f64)

Predict the leaf value and its variance for confidence estimation.

Returns (leaf_value, variance) where variance = 1 / (H_sum + lambda). A smaller variance indicates higher confidence in the leaf prediction.

Default implementation returns infinite variance (no confidence info).

Implementors§