Skip to main content

AdaptiveSGBT

Struct AdaptiveSGBT 

Source
pub struct AdaptiveSGBT<L: Loss = SquaredLoss> { /* private fields */ }
Available on crate feature alloc only.
Expand description

SGBT ensemble with an attached learning rate scheduler.

Before each train_one call, AdaptiveSGBT:

  1. Computes the current prediction to estimate loss.
  2. Queries the scheduler for the new learning rate.
  3. Sets the learning rate on the inner SGBT.
  4. Delegates the actual training step.

This allows any LRScheduler – exponential decay, cosine annealing, plateau reduction – to drive the ensemble’s learning rate without touching the core boosting logic.

§Loss Estimation

The scheduler receives squared error (target - prediction)² as its loss signal. This is computed from the current ensemble prediction before the training step, making it a one-step-lagged estimate. This works well for schedulers like PlateauLR that smooth over many steps.

Implementations§

Source§

impl AdaptiveSGBT<SquaredLoss>

Source

pub fn new(config: SGBTConfig, scheduler: impl LRScheduler + 'static) -> Self

Create an adaptive SGBT with squared loss (regression).

The initial learning rate is taken from the config and also stored as base_lr for reference.

use irithyll::ensemble::adaptive::AdaptiveSGBT;
use irithyll::ensemble::lr_schedule::ConstantLR;
use irithyll::SGBTConfig;

let config = SGBTConfig::builder()
    .n_steps(10)
    .learning_rate(0.05)
    .build()
    .unwrap();
let model = AdaptiveSGBT::new(config, ConstantLR::new(0.05));
Source§

impl<L: Loss> AdaptiveSGBT<L>

Source

pub fn with_loss( config: SGBTConfig, loss: L, scheduler: impl LRScheduler + 'static, ) -> Self

Create an adaptive SGBT with a specific loss function.

use irithyll::ensemble::adaptive::AdaptiveSGBT;
use irithyll::ensemble::lr_schedule::LinearDecayLR;
use irithyll::loss::logistic::LogisticLoss;
use irithyll::SGBTConfig;

let config = SGBTConfig::builder()
    .n_steps(10)
    .learning_rate(0.1)
    .build()
    .unwrap();
let model = AdaptiveSGBT::with_loss(
    config, LogisticLoss, LinearDecayLR::new(0.1, 0.001, 10_000),
);
Source

pub fn train_one_obs(&mut self, sample: &impl Observation)

Train on a single observation, adapting the learning rate first.

This is the generic version accepting any Observation implementor. For the StreamingLearner trait interface, use train_one(features, target, weight).

Source

pub fn current_lr(&self) -> f64

Current learning rate (as last set by the scheduler).

Source

pub fn base_lr(&self) -> f64

The initial learning rate from the original config.

Source

pub fn step_count(&self) -> u64

Total scheduler steps (equal to samples trained).

Source

pub fn last_loss(&self) -> f64

Most recent loss value passed to the scheduler.

Source

pub fn scheduler(&self) -> &dyn LRScheduler

Immutable access to the scheduler.

Source

pub fn scheduler_mut(&mut self) -> &mut dyn LRScheduler

Mutable access to the scheduler.

Source

pub fn inner(&self) -> &SGBT<L>

Immutable access to the inner SGBT model.

Source

pub fn inner_mut(&mut self) -> &mut SGBT<L>

Mutable access to the inner SGBT model.

Source

pub fn into_inner(self) -> SGBT<L>

Consume the wrapper and return the inner SGBT model.

Source

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

Predict using the inner SGBT model.

Trait Implementations§

Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<L: Loss> StreamingLearner for AdaptiveSGBT<L>

Source§

fn train_one(&mut self, features: &[f64], target: f64, weight: f64)

Train on a single observation with explicit sample weight. Read more
Source§

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

Predict the target for the given feature vector. Read more
Source§

fn n_samples_seen(&self) -> u64

Total number of observations trained on since creation or last reset.
Source§

fn reset(&mut self)

Reset the model to its initial (untrained) state. Read more
Source§

fn train(&mut self, features: &[f64], target: f64)

Train on a single observation with unit weight. Read more
Source§

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

Predict for each row in a feature matrix. Read more

Auto Trait Implementations§

§

impl<L> Freeze for AdaptiveSGBT<L>
where L: Freeze,

§

impl<L = SquaredLoss> !RefUnwindSafe for AdaptiveSGBT<L>

§

impl<L> Send for AdaptiveSGBT<L>

§

impl<L> Sync for AdaptiveSGBT<L>

§

impl<L> Unpin for AdaptiveSGBT<L>
where L: Unpin,

§

impl<L> UnsafeUnpin for AdaptiveSGBT<L>
where L: UnsafeUnpin,

§

impl<L = SquaredLoss> !UnwindSafe for AdaptiveSGBT<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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