#[non_exhaustive]pub struct LinearRegression { /* private fields */ }Expand description
Linear regression model.
Uses the OLS closed-form normal equations solution by default:
β = (XᵀX + αI)⁻¹ Xᵀy. Set alpha > 0 for Ridge (L2) regularization.
Alternative solvers (QR, SVD) provide better numerical stability for ill-conditioned or rank-deficient problems.
When the gpu feature is enabled and the dataset is large enough,
the XᵀX/Xᵀy computation is automatically offloaded to GPU compute shaders.
Implementations§
Source§impl LinearRegression
impl LinearRegression
Sourcepub fn fit_sparse(&mut self, features: &CscMatrix, target: &[f64]) -> Result<()>
pub fn fit_sparse(&mut self, features: &CscMatrix, target: &[f64]) -> Result<()>
Fit on sparse features (CSC format for column-oriented access).
Builds XᵀX and Xᵀy by iterating only over non-zero entries.
Sourcepub fn predict_sparse(&self, features: &CsrMatrix) -> Result<Vec<f64>>
pub fn predict_sparse(&self, features: &CsrMatrix) -> Result<Vec<f64>>
Predict from sparse features (CSR format for row-oriented access).
Sourcepub fn coefficients(&self) -> &[f64]
pub fn coefficients(&self) -> &[f64]
Get learned coefficients.
Trait Implementations§
Source§impl Clone for LinearRegression
impl Clone for LinearRegression
Source§fn clone(&self) -> LinearRegression
fn clone(&self) -> LinearRegression
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for LinearRegression
impl Default for LinearRegression
Auto Trait Implementations§
impl Freeze for LinearRegression
impl RefUnwindSafe for LinearRegression
impl Send for LinearRegression
impl Sync for LinearRegression
impl Unpin for LinearRegression
impl UnsafeUnpin for LinearRegression
impl UnwindSafe for LinearRegression
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> 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