pub struct AdaptiveRandomForest { /* private fields */ }alloc only.Expand description
Adaptive Random Forest for streaming classification.
An ensemble of n_trees streaming learners, each trained on a
Poisson-weighted bootstrap with a random feature subspace. ADWIN drift
detection automatically resets individual trees when their error rate
changes significantly.
§Example
use irithyll::{AdaptiveRandomForest, StreamingLearner};
use irithyll::ensemble::adaptive_forest::ARFConfig;
use irithyll::learners::linear::StreamingLinearModel;
let config = ARFConfig::builder(5).lambda(6.0).build().unwrap();
let mut arf = AdaptiveRandomForest::new(config, || {
Box::new(StreamingLinearModel::new(0.01))
});
arf.train_one(&[1.0, 0.0], 0.0);
let pred = arf.predict(&[1.0, 0.0]);Implementations§
Source§impl AdaptiveRandomForest
impl AdaptiveRandomForest
Sourcepub fn new<F>(config: ARFConfig, factory: F) -> Self
pub fn new<F>(config: ARFConfig, factory: F) -> Self
Create a new ARF with the given config and learner factory.
The factory closure is called n_trees times to create the initial
ensemble, and again whenever a tree is replaced after drift detection.
Sourcepub fn predict(&self, features: &[f64]) -> f64
pub fn predict(&self, features: &[f64]) -> f64
Predict by majority vote across all trees.
Each tree casts a vote for a class (prediction rounded to nearest integer). The class with the most votes wins.
Sourcepub fn predict_votes(&self, features: &[f64]) -> Vec<(f64, u64)>
pub fn predict_votes(&self, features: &[f64]) -> Vec<(f64, u64)>
Vote counts per predicted class.
Sourcepub fn n_samples_seen(&self) -> u64
pub fn n_samples_seen(&self) -> u64
Total samples processed.
Sourcepub fn tree_accuracies(&self) -> Vec<f64>
pub fn tree_accuracies(&self) -> Vec<f64>
Per-tree accuracy (correct / evaluated).
Sourcepub fn n_drifts_detected(&self) -> usize
pub fn n_drifts_detected(&self) -> usize
Total number of drift-triggered tree replacements.