pub struct PlsResult {
pub weights: FdMatrix,
pub scores: FdMatrix,
pub loadings: FdMatrix,
pub x_means: Vec<f64>,
}Expand description
Result of PLS regression.
Fields§
§weights: FdMatrixWeight vectors, m x ncomp
scores: FdMatrixScore vectors, n x ncomp
loadings: FdMatrixLoading vectors, m x ncomp
x_means: Vec<f64>Column means of the training data, length m
Implementations§
Source§impl PlsResult
impl PlsResult
Sourcepub fn project(&self, data: &FdMatrix) -> Result<FdMatrix, FdarError>
pub fn project(&self, data: &FdMatrix) -> Result<FdMatrix, FdarError>
Project new functional data onto the PLS score space.
Centers the input data by subtracting the column means estimated during PLS fitting, then iteratively projects and deflates through each PLS component using the stored weight and loading vectors.
§Arguments
data- Matrix (n_new x m) of new observations
§Errors
Returns FdarError::InvalidDimension if the number of columns in
data does not match the number of predictor variables used during
PLS fitting.
§Examples
use fdars_core::matrix::FdMatrix;
use fdars_core::regression::fdata_to_pls_1d;
let x = FdMatrix::from_column_major(
(0..100).map(|i| (i as f64 * 0.1).sin()).collect(),
10, 10,
).unwrap();
let y: Vec<f64> = (0..10).map(|i| i as f64 * 0.5).collect();
let pls = fdata_to_pls_1d(&x, &y, 3).unwrap();
// Project the original data
let scores = pls.project(&x).unwrap();
assert_eq!(scores.shape(), (10, 3));
// Project new data
let new_x = FdMatrix::from_column_major(
(0..20).map(|i| (i as f64 * 0.2).cos()).collect(),
2, 10,
).unwrap();
let new_scores = pls.project(&new_x).unwrap();
assert_eq!(new_scores.shape(), (2, 3));Trait Implementations§
impl StructuralPartialEq for PlsResult
Auto Trait Implementations§
impl Freeze for PlsResult
impl RefUnwindSafe for PlsResult
impl Send for PlsResult
impl Sync for PlsResult
impl Unpin for PlsResult
impl UnsafeUnpin for PlsResult
impl UnwindSafe for PlsResult
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 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.