pub struct ParallelSGBT<L: Loss = SquaredLoss> { /* private fields */ }Expand description
Parallel SGBT ensemble with delayed gradient updates.
All boosting steps train concurrently using the full ensemble prediction for gradient computation. Predictions remain sequential (deterministic) – only training is parallelized.
Generic over L: Loss so the loss function’s gradient/hessian calls
are monomorphized (inlined) into the training loop — no virtual dispatch.
§Differences from SGBT
| Aspect | SGBT | ParallelSGBT |
|---|---|---|
| Gradient target | Rolling (step-by-step) | Full ensemble prediction |
| Step training | Sequential | Parallel (rayon) |
| Prediction | Sequential | Sequential (identical) |
| Convergence | Optimal | Slightly delayed |
| Throughput | 1x | ~Nx (N = cores) |
Implementations§
Source§impl ParallelSGBT<SquaredLoss>
impl ParallelSGBT<SquaredLoss>
Sourcepub fn new(config: SGBTConfig) -> Self
pub fn new(config: SGBTConfig) -> Self
Create a new parallel SGBT ensemble with squared loss (regression).
Source§impl<L: Loss> ParallelSGBT<L>
impl<L: Loss> ParallelSGBT<L>
Sourcepub fn with_loss(config: SGBTConfig, loss: L) -> Self
pub fn with_loss(config: SGBTConfig, loss: L) -> Self
Create a new parallel SGBT ensemble with a specific loss function.
The loss is stored by value (monomorphized), giving zero-cost gradient/hessian dispatch.
use irithyll::SGBTConfig;
use irithyll::ensemble::parallel::ParallelSGBT;
use irithyll::loss::logistic::LogisticLoss;
let config = SGBTConfig::builder().n_steps(10).build().unwrap();
let model = ParallelSGBT::with_loss(config, LogisticLoss);Sourcepub fn train_one(&mut self, sample: &impl Observation)
pub fn train_one(&mut self, sample: &impl Observation)
Train on a single observation using delayed gradient updates.
Accepts any type implementing Observation, including Sample,
SampleRef, or tuples like (&[f64], f64).
All boosting steps receive the same gradient/hessian computed from
the full ensemble prediction, then train in parallel (when the
parallel feature is enabled).
Sourcepub fn train_batch<O: Observation>(&mut self, samples: &[O])
pub fn train_batch<O: Observation>(&mut self, samples: &[O])
Train on a batch of observations.
Sourcepub fn predict(&self, features: &[f64]) -> f64
pub fn predict(&self, features: &[f64]) -> f64
Predict the raw output for a feature vector.
Prediction is always sequential and deterministic, regardless of whether training uses parallelism.
Sourcepub fn predict_transformed(&self, features: &[f64]) -> f64
pub fn predict_transformed(&self, features: &[f64]) -> f64
Predict with loss transform applied (e.g., sigmoid for logistic loss).
Sourcepub fn predict_proba(&self, features: &[f64]) -> f64
pub fn predict_proba(&self, features: &[f64]) -> f64
Predict probability (alias for predict_transformed).
Sourcepub fn total_leaves(&self) -> usize
pub fn total_leaves(&self) -> usize
Total leaves across all active trees.
Sourcepub fn n_samples_seen(&self) -> u64
pub fn n_samples_seen(&self) -> u64
Total samples trained.
Sourcepub fn base_prediction(&self) -> f64
pub fn base_prediction(&self) -> f64
The current base prediction.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Whether the base prediction has been initialized.
Sourcepub fn config(&self) -> &SGBTConfig
pub fn config(&self) -> &SGBTConfig
Access the configuration.
Sourcepub fn feature_importances(&self) -> Vec<f64>
pub fn feature_importances(&self) -> Vec<f64>
Feature importances based on accumulated split gains across all trees.
Returns normalized importances (sum to 1.0) indexed by feature. Returns an empty Vec if no splits have occurred yet.
Trait Implementations§
Auto Trait Implementations§
impl<L> Freeze for ParallelSGBT<L>where
L: Freeze,
impl<L = SquaredLoss> !RefUnwindSafe for ParallelSGBT<L>
impl<L> Send for ParallelSGBT<L>
impl<L> Sync for ParallelSGBT<L>
impl<L> Unpin for ParallelSGBT<L>where
L: Unpin,
impl<L> UnsafeUnpin for ParallelSGBT<L>where
L: UnsafeUnpin,
impl<L = SquaredLoss> !UnwindSafe for ParallelSGBT<L>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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