Skip to main content

MulticlassSGBT

Struct MulticlassSGBT 

Source
pub struct MulticlassSGBT { /* private fields */ }
Available on crate feature alloc only.
Expand description

Multi-class SGBT using one-vs-rest committee of ensembles.

Each class gets its own SGBT<SoftmaxLoss> trained with softmax (logistic per-class) loss. The concrete loss type is monomorphized for each committee – no Box<dyn Loss> overhead.

Predictions are softmax-normalized across all class committees.

Implementations§

Source§

impl MulticlassSGBT

Source

pub fn new(config: SGBTConfig, n_classes: usize) -> Result<Self>

Create a new multi-class SGBT.

§Errors

Returns IrithyllError::InvalidConfig if n_classes < 2.

Source

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

Train on a single observation.

The observation’s target should be the class index as f64 (0.0, 1.0, 2.0, …).

Uses SampleRef internally to avoid cloning feature vectors for each committee (N classes = 0 clones instead of N clones).

Source

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

Train on a batch of observations.

Source

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

Predict class probabilities via softmax normalization.

Returns a vector of length n_classes summing to ~1.0.

Source

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

Predict the most likely class.

Source

pub fn n_classes(&self) -> usize

Number of classes.

Source

pub fn n_samples_seen(&self) -> u64

Total samples trained.

Source

pub fn reset(&mut self)

Reset all committees.

Trait Implementations§

Source§

impl Debug for MulticlassSGBT

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.