Skip to main content

QuantileRegressorSGBT

Struct QuantileRegressorSGBT 

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

Non-crossing multi-quantile SGBT regressor.

Maintains K independent SGBT<QuantileLoss> models – one per quantile level – and applies the Pool Adjacent Violators Algorithm (PAVA) to predictions to guarantee non-crossing quantile estimates.

§Non-crossing guarantee

For quantile levels tau_1 < tau_2 < … < tau_K, the predicted values q_hat(tau_1) <= q_hat(tau_2) <= … <= q_hat(tau_K) after PAVA enforcement. This makes the output suitable for prediction intervals, conditional density estimation, and risk quantification.

Implementations§

Source§

impl QuantileRegressorSGBT

Source

pub fn new(config: SGBTConfig, quantiles: &[f64]) -> Result<Self>

Create a new multi-quantile regressor.

Quantile levels are automatically sorted. Each level must be in (0, 1) and there must be at least one level.

§Errors

Returns IrithyllError::InvalidConfig if:

  • quantiles is empty
  • any quantile is not in (0, 1)
  • duplicate quantile levels exist
Source

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

Train all quantile models on a single observation.

Each model independently learns from the same sample, targeting its respective quantile level.

Source

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

Train on a batch of observations.

Source

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

Predict quantile values with PAVA non-crossing enforcement.

Returns a Vec<f64> of length n_quantiles where:

  • result[i] is the predicted quantile at level quantiles[i]
  • result[0] <= result[1] <= ... <= result[K-1] (guaranteed)
Source

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

Predict raw quantile values WITHOUT non-crossing enforcement.

This may produce crossing predictions. Use predict for the PAVA-enforced version.

Source

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

Predict a symmetric prediction interval at coverage level 1 - alpha.

Returns (lower, median, upper) if the model was constructed with quantile levels that include alpha/2, 0.5, and 1 - alpha/2.

If the exact levels are not present, returns the closest available quantile predictions with PAVA enforcement applied.

Source

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

Batch prediction with PAVA enforcement.

Source

pub fn n_quantiles(&self) -> usize

Number of quantile levels.

Source

pub fn quantiles(&self) -> &[f64]

The sorted quantile levels.

Source

pub fn n_samples_seen(&self) -> u64

Total samples seen.

Source

pub fn model(&self, idx: usize) -> &SGBT<QuantileLoss>

Access the model for a specific quantile index.

§Panics

Panics if idx >= n_quantiles.

Source

pub fn models(&self) -> &[SGBT<QuantileLoss>]

Access all quantile models.

Source

pub fn reset(&mut self)

Reset all quantile models.

Trait Implementations§

Source§

impl Clone for QuantileRegressorSGBT

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 Debug for QuantileRegressorSGBT

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