pub struct RegressionResults<F>{Show 14 fields
pub coefficients: Array1<F>,
pub std_errors: Array1<F>,
pub t_values: Array1<F>,
pub p_values: Array1<F>,
pub conf_intervals: Array2<F>,
pub r_squared: F,
pub adj_r_squared: F,
pub f_statistic: F,
pub f_p_value: F,
pub residual_std_error: F,
pub df_residuals: usize,
pub residuals: Array1<F>,
pub fitted_values: Array1<F>,
pub inlier_mask: Vec<bool>,
}
Expand description
Structure to hold detailed regression results
Fields§
§coefficients: Array1<F>
Coefficients of the regression model
std_errors: Array1<F>
Standard errors for the coefficients
t_values: Array1<F>
t-statistics for each coefficient
p_values: Array1<F>
p-values for each coefficient
conf_intervals: Array2<F>
Confidence intervals for each coefficient (lower, upper)
r_squared: F
R-squared value (coefficient of determination)
adj_r_squared: F
Adjusted R-squared value
f_statistic: F
F-statistic for the regression
f_p_value: F
p-value for the F-statistic
residual_std_error: F
Residual standard error
df_residuals: usize
Degrees of freedom
residuals: Array1<F>
Residuals
fitted_values: Array1<F>
Fitted (predicted) values
inlier_mask: Vec<bool>
Boolean mask indicating inliers for robust methods like RANSAC This is only populated for methods that explicitly identify inliers/outliers
Implementations§
Source§impl<F> RegressionResults<F>
impl<F> RegressionResults<F>
Sourcepub fn predict(&self, xnew: &ArrayView2<'_, F>) -> StatsResult<Array1<F>>
pub fn predict(&self, xnew: &ArrayView2<'_, F>) -> StatsResult<Array1<F>>
Predict values using the regression model on new data.
§Arguments
x_new
- New independent variables data (must have the same number of columns as the original x data)
§Returns
Array of predicted values for each row in x_new.
§Examples
use ndarray::{array, Array2};
use scirs2_stats::linear_regression;
// Fit a model
let x = Array2::from_shape_vec((3, 2), vec![
1.0, 1.0, // 3 observations with 2 variables (intercept and x1)
1.0, 2.0,
1.0, 3.0,
]).unwrap();
let y = array![3.0, 5.0, 7.0]; // y = 1 + 2*x1
let model = linear_regression(&x.view(), &y.view(), None).unwrap();
// Predict for new data
let x_new = Array2::from_shape_vec((2, 2), vec![
1.0, 4.0, // 2 new observations
1.0, 5.0,
]).unwrap();
let predictions = model.predict(&x_new.view()).unwrap();
// Check predictions: y = 1 + 2*x1
assert!((predictions[0] - 9.0f64).abs() < 1e-8f64); // 1 + 2*4 = 9
assert!((predictions[1] - 11.0f64).abs() < 1e-8f64); // 1 + 2*5 = 11
Auto Trait Implementations§
impl<F> Freeze for RegressionResults<F>where
F: Freeze,
impl<F> RefUnwindSafe for RegressionResults<F>where
F: RefUnwindSafe,
impl<F> Send for RegressionResults<F>where
F: Send,
impl<F> Sync for RegressionResults<F>where
F: Sync,
impl<F> Unpin for RegressionResults<F>where
F: Unpin,
impl<F> UnwindSafe for RegressionResults<F>where
F: UnwindSafe + RefUnwindSafe,
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.