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 toSquaredLossfor regression. AnyL: Loss + Cloneis 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>
impl<L: Loss> SGBTLearner<L>
Sourcepub fn new(model: SGBT<L>) -> Self
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.
Sourcepub fn inner(&self) -> &SGBT<L>
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.
Sourcepub fn inner_mut(&mut self) -> &mut SGBT<L>
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.
Sourcepub fn into_inner(self) -> SGBT<L>
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>
impl SGBTLearner<SquaredLoss>
Sourcepub fn from_config(config: SGBTConfig) -> Self
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> Debug for SGBTLearner<L>
impl<L: Loss> Debug for SGBTLearner<L>
Source§impl<L: Loss> StreamingLearner for SGBTLearner<L>
impl<L: Loss> StreamingLearner for SGBTLearner<L>
Source§fn train_one(&mut self, features: &[f64], target: f64, weight: f64)
fn train_one(&mut self, features: &[f64], target: f64, weight: f64)
Source§fn predict(&self, features: &[f64]) -> f64
fn predict(&self, features: &[f64]) -> f64
Source§fn n_samples_seen(&self) -> u64
fn n_samples_seen(&self) -> u64
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> 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