Skip to main content

ParallelSGBT

Struct ParallelSGBT 

Source
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

AspectSGBTParallelSGBT
Gradient targetRolling (step-by-step)Full ensemble prediction
Step trainingSequentialParallel (rayon)
PredictionSequentialSequential (identical)
ConvergenceOptimalSlightly delayed
Throughput1x~Nx (N = cores)

Implementations§

Source§

impl ParallelSGBT<SquaredLoss>

Source

pub fn new(config: SGBTConfig) -> Self

Create a new parallel SGBT ensemble with squared loss (regression).

Source§

impl<L: Loss> ParallelSGBT<L>

Source

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);
Source

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

Source

pub fn train_batch<O: Observation>(&mut self, samples: &[O])

Train on a batch of observations.

Source

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.

Source

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

Predict with loss transform applied (e.g., sigmoid for logistic loss).

Source

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

Predict probability (alias for predict_transformed).

Source

pub fn predict_batch(&self, feature_matrix: &[Vec<f64>]) -> Vec<f64>

Batch prediction.

Source

pub fn n_steps(&self) -> usize

Number of boosting steps.

Source

pub fn n_trees(&self) -> usize

Total trees (active + alternates).

Source

pub fn total_leaves(&self) -> usize

Total leaves across all active trees.

Source

pub fn n_samples_seen(&self) -> u64

Total samples trained.

Source

pub fn base_prediction(&self) -> f64

The current base prediction.

Source

pub fn is_initialized(&self) -> bool

Whether the base prediction has been initialized.

Source

pub fn config(&self) -> &SGBTConfig

Access the configuration.

Source

pub fn loss(&self) -> &L

Immutable access to the loss function.

Source

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.

Source

pub fn reset(&mut self)

Reset the ensemble to initial state.

Trait Implementations§

Source§

impl<L: Loss + Clone> Clone for ParallelSGBT<L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Loss> Debug for ParallelSGBT<L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more