pub struct LinearRegression<T = f64>{
pub slope: T,
pub intercept: T,
pub r_squared: T,
pub standard_error: T,
pub n: usize,
}Expand description
Linear regression model that fits a line to data points.
Fields§
§slope: TSlope of the regression line (coefficient of x)
intercept: TY-intercept of the regression line
r_squared: TCoefficient of determination (R²) - goodness of fit
standard_error: TStandard error of the estimate
n: usizeNumber of data points used for regression
Implementations§
Source§impl<T> LinearRegression<T>
impl<T> LinearRegression<T>
Sourcepub fn predict_many<U>(&self, x_values: &[U]) -> Vec<T>
pub fn predict_many<U>(&self, x_values: &[U]) -> Vec<T>
Sourcepub fn confidence_interval<U>(
&self,
x: U,
confidence_level: f64,
) -> Option<(T, T)>
pub fn confidence_interval<U>( &self, x: U, confidence_level: f64, ) -> Option<(T, T)>
Sourcepub fn correlation_coefficient(&self) -> T
pub fn correlation_coefficient(&self) -> T
Get the correlation coefficient (r)
Trait Implementations§
Source§impl<T> Clone for LinearRegression<T>
impl<T> Clone for LinearRegression<T>
Source§fn clone(&self) -> LinearRegression<T>
fn clone(&self) -> LinearRegression<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for LinearRegression<T>
impl<T> Debug for LinearRegression<T>
Source§impl<T> Default for LinearRegression<T>
impl<T> Default for LinearRegression<T>
Source§impl<'de, T> Deserialize<'de> for LinearRegression<T>
impl<'de, T> Deserialize<'de> for LinearRegression<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for LinearRegression<T>where
T: Freeze,
impl<T> RefUnwindSafe for LinearRegression<T>where
T: RefUnwindSafe,
impl<T> Send for LinearRegression<T>where
T: Send,
impl<T> Sync for LinearRegression<T>where
T: Sync,
impl<T> Unpin for LinearRegression<T>where
T: Unpin,
impl<T> UnwindSafe for LinearRegression<T>where
T: 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> 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