Skip to main content

SGBTLearner

Struct SGBTLearner 

Source
pub struct SGBTLearner<L: Loss = SquaredLoss> { /* private fields */ }
Expand description

Adapter that wraps an SGBT ensemble into the StreamingLearner trait.

This is the primary way to use SGBT models in polymorphic stacking ensembles. The loss function L is monomorphized at compile time for zero-cost gradient dispatch, while the StreamingLearner trait provides the uniform interface needed by meta-learners.

§Type Parameter

  • L — loss function type, defaulting to SquaredLoss for regression. Any L: Loss + Clone is supported.

§Examples

use irithyll::learner::SGBTLearner;
use irithyll::SGBTConfig;

// Default squared loss:
let config = SGBTConfig::builder().n_steps(5).build().unwrap();
let learner = SGBTLearner::from_config(config);
use irithyll::learner::SGBTLearner;
use irithyll::{SGBTConfig, SGBT};
use irithyll::loss::logistic::LogisticLoss;

// Custom loss via wrapping an existing SGBT:
let config = SGBTConfig::builder().n_steps(5).build().unwrap();
let model = SGBT::with_loss(config, LogisticLoss);
let learner = SGBTLearner::new(model);

Implementations§

Source§

impl<L: Loss> SGBTLearner<L>

Source

pub fn new(model: SGBT<L>) -> Self

Wrap an existing SGBT model into a SGBTLearner.

The model retains all of its current state (trained trees, samples seen, etc.). This enables wrapping a partially-trained model.

Source

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

Immutable access to the underlying SGBT model.

Useful for inspecting model internals (config, base prediction, number of steps) without consuming the adapter.

Source

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

Mutable access to the underlying SGBT model.

Enables calling SGBT-specific methods (e.g., predict_transformed, serialization) that are not part of the StreamingLearner interface.

Source

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

Consume the adapter and return the underlying SGBT model.

This is useful when you need to serialize the model or switch from polymorphic back to monomorphic usage.

Source§

impl SGBTLearner<SquaredLoss>

Source

pub fn from_config(config: SGBTConfig) -> Self

Create a new SGBTLearner with squared loss from a configuration.

This is the most common constructor for regression tasks. For custom losses, construct the SGBT first with SGBT::with_loss and wrap it via SGBTLearner::new.

§Examples
use irithyll::learner::{SGBTLearner, StreamingLearner};
use irithyll::SGBTConfig;

let config = SGBTConfig::builder()
    .n_steps(10)
    .learning_rate(0.05)
    .build()
    .unwrap();
let learner = SGBTLearner::from_config(config);
assert_eq!(learner.n_samples_seen(), 0);

Trait Implementations§

Source§

impl<L: Loss + Clone> Clone for SGBTLearner<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 SGBTLearner<L>

Source§

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

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

impl<L: Loss> StreamingLearner for SGBTLearner<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 SGBTLearner<L>
where L: Freeze,

§

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

§

impl<L> Send for SGBTLearner<L>

§

impl<L> Sync for SGBTLearner<L>

§

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

§

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

§

impl<L = SquaredLoss> !UnwindSafe for SGBTLearner<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