RegressionResults

Struct RegressionResults 

Source
pub struct RegressionResults<F>
where F: Float + Debug + Display + 'static,
{
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>
where F: Float + Debug + Display + 'static,

Source

pub fn predict(&self, xnew: &ArrayView2<'_, F>) -> StatsResult<Array1<F>>
where F: Mul<Output = F> + Sum<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
Source

pub fn summary(&self) -> String

Return a summary of the regression results as a string.

§Returns

A formatted string with regression statistics.

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>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V