pub struct LinearRegression<F> {
pub fit_intercept: bool,
/* private fields */
}Expand description
Ordinary least squares linear regression.
Solves the normal equations using QR decomposition for numerical
stability. The fit_intercept option controls whether a bias
(intercept) term is included.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float> LinearRegression<F>
impl<F: Float> LinearRegression<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LinearRegression with default settings.
Defaults: fit_intercept = true.
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 LinearRegression<F>
impl<F: Clone> Clone for LinearRegression<F>
Source§fn clone(&self) -> LinearRegression<F>
fn clone(&self) -> LinearRegression<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 LinearRegression<F>
impl<F: Debug> Debug for LinearRegression<F>
Source§impl<F: Float> Default for LinearRegression<F>
impl<F: Float> Default for LinearRegression<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for LinearRegression<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for LinearRegression<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedLinearRegression<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedLinearRegression<F>, FerroError>
Fit the linear regression model.
Uses the centering trick with Cholesky normal equations for speed. Falls back to QR decomposition via faer if the normal equations are ill-conditioned.
§Errors
Returns FerroError::ShapeMismatch if the number of samples in x
and y differ.
Returns FerroError::InsufficientSamples if there are fewer samples
than features.
Returns FerroError::NumericalInstability if the system is singular.
Source§type Fitted = FittedLinearRegression<F>
type Fitted = FittedLinearRegression<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl PipelineEstimator<f64> for LinearRegression<f64>
impl PipelineEstimator<f64> for LinearRegression<f64>
Source§fn fit_pipeline(
&self,
x: &Array2<f64>,
y: &Array1<f64>,
) -> Result<Box<dyn FittedPipelineEstimator<f64>>, FerroError>
fn fit_pipeline( &self, x: &Array2<f64>, y: &Array1<f64>, ) -> Result<Box<dyn FittedPipelineEstimator<f64>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for LinearRegression<F>
impl<F> RefUnwindSafe for LinearRegression<F>where
F: RefUnwindSafe,
impl<F> Send for LinearRegression<F>where
F: Send,
impl<F> Sync for LinearRegression<F>where
F: Sync,
impl<F> Unpin for LinearRegression<F>where
F: Unpin,
impl<F> UnsafeUnpin for LinearRegression<F>
impl<F> UnwindSafe for LinearRegression<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