Skip to main content

irithyll_core/ensemble/
mod.rs

1//! SGBT ensemble orchestrator -- the core boosting loop.
2//!
3//! Implements Streaming Gradient Boosted Trees (Gunasekara et al., 2024):
4//! a sequence of boosting steps, each owning a streaming tree and drift detector,
5//! with automatic tree replacement when concept drift is detected.
6//!
7//! # Algorithm
8//!
9//! For each incoming sample `(x, y)`:
10//! 1. Compute the current ensemble prediction: `F(x) = base + lr * Σ tree_s(x)`
11//! 2. For each boosting step `s = 1..N`:
12//!    - Compute gradient `g = loss.gradient(y, current_pred)`
13//!    - Compute hessian `h = loss.hessian(y, current_pred)`
14//!    - Feed `(x, g, h)` to tree `s` (which internally uses weighted squared loss)
15//!    - Update `current_pred += lr * tree_s.predict(x)`
16//! 3. The ensemble adapts incrementally, with each tree targeting the residual
17//!    of all preceding trees.
18
19pub mod adaptive;
20pub mod adaptive_forest;
21pub mod bagged;
22pub mod config;
23pub mod core;
24pub mod diagnostics;
25pub mod distributional;
26pub mod lr_schedule;
27pub mod moe;
28pub mod moe_distributional;
29pub mod multi_target;
30pub mod multiclass;
31#[cfg(feature = "parallel")]
32#[cfg_attr(docsrs, doc(cfg(feature = "parallel")))]
33pub mod parallel;
34pub mod quantile_regressor;
35pub mod replacement;
36pub mod stacked;
37pub mod step;
38pub mod variants;
39
40use alloc::boxed::Box;
41
42use crate::loss::Loss;
43#[allow(unused_imports)] // Used in doc links + tests
44use crate::sample::Sample;
45#[cfg(feature = "_serde_support")]
46use crate::tree::builder::TreeConfig;
47
48// Re-export core types from the core module
49pub use core::SGBT;
50
51/// Type alias for an SGBT model using dynamic (boxed) loss dispatch.
52///
53/// Use this when the loss function is determined at runtime (e.g., when
54/// deserializing a model from JSON where the loss type is stored as a tag).
55///
56/// For compile-time loss dispatch (preferred for performance), use
57/// `SGBT<LogisticLoss>`, `SGBT<HuberLoss>`, etc.
58pub type DynSGBT = SGBT<Box<dyn Loss>>;
59
60// Stub for methods to be implemented.
61// This file serves as the hub for the ensemble module.
62// Actual implementation methods will be added across multiple files
63// in a future wave (accessors, inference, inspection, train, etc.).