pub struct QuantileRegressor<F> {
pub quantile: F,
pub alpha: F,
pub max_iter: usize,
pub tol: F,
pub fit_intercept: bool,
}Expand description
Quantile Regressor — conditional quantile estimation via IRLS.
Minimises the pinball loss with optional L1 regularization. The IRLS
weights are w_i = 1 / (2 * max(|r_i|, eps)), which gives the
iteratively reweighted least absolute deviations procedure.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§quantile: FThe quantile to estimate (must be in (0, 1)). Default 0.5 (median).
alpha: FL1 regularization strength.
max_iter: usizeMaximum number of IRLS iterations.
tol: FConvergence tolerance on the maximum coefficient change.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float + FromPrimitive> QuantileRegressor<F>
impl<F: Float + FromPrimitive> QuantileRegressor<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new QuantileRegressor with default settings.
Defaults: quantile = 0.5, alpha = 1.0, max_iter = 1000,
tol = 1e-5, fit_intercept = true.
Sourcepub fn with_quantile(self, quantile: F) -> Self
pub fn with_quantile(self, quantile: F) -> Self
Set the quantile to estimate.
Must be strictly between 0 and 1.
Sourcepub fn with_alpha(self, alpha: F) -> Self
pub fn with_alpha(self, alpha: F) -> Self
Set the L1 regularization strength.
Sourcepub fn with_max_iter(self, max_iter: usize) -> Self
pub fn with_max_iter(self, max_iter: usize) -> Self
Set the maximum number of IRLS iterations.
Sourcepub fn with_fit_intercept(self, fit_intercept: bool) -> Self
pub fn with_fit_intercept(self, fit_intercept: bool) -> Self
Set whether to fit an intercept term.
Trait Implementations§
Source§impl<F: Clone> Clone for QuantileRegressor<F>
impl<F: Clone> Clone for QuantileRegressor<F>
Source§fn clone(&self) -> QuantileRegressor<F>
fn clone(&self) -> QuantileRegressor<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for QuantileRegressor<F>
impl<F: Debug> Debug for QuantileRegressor<F>
Source§impl<F: Float + FromPrimitive> Default for QuantileRegressor<F>
impl<F: Float + FromPrimitive> Default for QuantileRegressor<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for QuantileRegressor<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for QuantileRegressor<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedQuantileRegressor<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedQuantileRegressor<F>, FerroError>
Fit the quantile regression model via IRLS.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InsufficientSamples— zero samples.FerroError::InvalidParameter— quantile outside (0, 1) or negative alpha.
Source§type Fitted = FittedQuantileRegressor<F>
type Fitted = FittedQuantileRegressor<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F> PipelineEstimator<F> for QuantileRegressor<F>
impl<F> PipelineEstimator<F> for QuantileRegressor<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for QuantileRegressor<F>where
F: Freeze,
impl<F> RefUnwindSafe for QuantileRegressor<F>where
F: RefUnwindSafe,
impl<F> Send for QuantileRegressor<F>where
F: Send,
impl<F> Sync for QuantileRegressor<F>where
F: Sync,
impl<F> Unpin for QuantileRegressor<F>where
F: Unpin,
impl<F> UnsafeUnpin for QuantileRegressor<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for QuantileRegressor<F>where
F: UnwindSafe,
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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