pub struct Lars<F> {
pub n_nonzero_coefs: Option<usize>,
pub fit_intercept: bool,
/* private fields */
}Expand description
Least Angle Regression (LARS).
Builds a sparse linear model by iteratively adding the feature most correlated with the residual. At each step, OLS is re-solved on the current active set.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§n_nonzero_coefs: Option<usize>Maximum number of non-zero coefficients. Defaults to None,
meaning use all features.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float> Lars<F>
impl<F: Float> Lars<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new Lars with default settings.
Defaults: n_nonzero_coefs = None, fit_intercept = true.
Sourcepub fn with_n_nonzero_coefs(self, n: usize) -> Self
pub fn with_n_nonzero_coefs(self, n: usize) -> Self
Set the maximum number of non-zero coefficients.
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: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for Lars<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for Lars<F>
Source§fn fit(&self, x: &Array2<F>, y: &Array1<F>) -> Result<FittedLars<F>, FerroError>
fn fit(&self, x: &Array2<F>, y: &Array1<F>) -> Result<FittedLars<F>, FerroError>
Fit the LARS model.
Iteratively adds the feature most correlated with the residual to the active set and solves OLS on that subset.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InsufficientSamples— zero samples.FerroError::InvalidParameter—n_nonzero_coefsexceeds feature count.
Source§type Fitted = FittedLars<F>
type Fitted = FittedLars<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F> PipelineEstimator<F> for Lars<F>
impl<F> PipelineEstimator<F> for Lars<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>
Fit this estimator on the given data. Read more
Auto Trait Implementations§
impl<F> Freeze for Lars<F>
impl<F> RefUnwindSafe for Lars<F>where
F: RefUnwindSafe,
impl<F> Send for Lars<F>where
F: Send,
impl<F> Sync for Lars<F>where
F: Sync,
impl<F> Unpin for Lars<F>where
F: Unpin,
impl<F> UnsafeUnpin for Lars<F>
impl<F> UnwindSafe for Lars<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
Mutably borrows from an owned value. Read more
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>
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 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>
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