#[non_exhaustive]pub struct JfpcaModel {Show 14 fields
pub karcher_mean: Vec<f64>,
pub mean_q: Vec<f64>,
pub mean_psi: Vec<f64>,
pub vert_component: FdMatrix,
pub horiz_component: FdMatrix,
pub balance_c: f64,
pub argvals: Vec<f64>,
pub eigenvalues: Vec<f64>,
pub ncomp: usize,
pub joint_result: JointFpcaResult,
pub lambda: f64,
pub training_gammas: FdMatrix,
pub training_aligned: FdMatrix,
pub mean_srsf: Vec<f64>,
}Expand description
Trained joint-FPCA model that stores the full basis for out-of-sample projection.
Created by jfpca_fit; used via JfpcaModel::transform.
All fields are public and #[non_exhaustive] — new fields may be added in
future minor versions without breaking existing destructuring.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.karcher_mean: Vec<f64>Trained Karcher-mean template curve (length m).
New curves are aligned to this fixed template during JfpcaModel::transform.
mean_q: Vec<f64>Mean of augmented SRSF matrix (length m+1).
Used to center new curves’ augmented SRSFs using the training-time mean, preserving coordinate-system alignment.
mean_psi: Vec<f64>Trained ψ Karcher mean on the Hilbert sphere (length m).
Used to compute shooting vectors for new curves. Captured from
horiz_fpca at fit time (discarded by joint_fpca).
vert_component: FdMatrixVertical (amplitude) eigenvector component (ncomp × (m+1)).
Rows are the amplitude rows of the joint right-singular vectors V^T.
horiz_component: FdMatrixHorizontal (phase) eigenvector component (ncomp × m).
Rows are the phase rows of the joint right-singular vectors V^T.
balance_c: f64Phase-vs-amplitude balance weight used at training time.
argvals: Vec<f64>Evaluation grid (length m).
New curves passed to JfpcaModel::transform must have the same number
of columns; a mismatch returns FdarError::InvalidDimension.
eigenvalues: Vec<f64>Eigenvalues (variance explained, length ncomp).
ncomp: usizeNumber of principal components (clamped to n-1 at training time).
joint_result: JointFpcaResultFull joint FPCA result from training (contains training scores).
lambda: f64Warp penalty weight used at training time.
Stored so the transform step can reproduce the same alignment geodesic.
training_gammas: FdMatrixWarping functions from the training-time Karcher alignment (n_train × m).
Stored so downstream consumers can reproduce the exact training-set scores
using the scoring formula directly, without re-running alignment. The
Karcher-mean algorithm post-centers its gammas (via sqrt_mean_inverse),
so these differ from align_to_target gammas even for the training curves.
training_aligned: FdMatrixTraining curves aligned to the Karcher-mean template (n_train × m).
Stored alongside JfpcaModel::training_gammas for exact training-set
reproducibility.
mean_srsf: Vec<f64>Post-centered Karcher-mean SRSF (length m).
This is mu_q_centered from the Karcher iteration — the SRSF used to
reconstruct JfpcaModel::karcher_mean via srsf_inverse:
karcher_mean = srsf_inverse(mean_srsf, argvals, karcher_mean[0]).
Stored so JfpcaModel::principal_directions can reconstruct amplitude
curves at c = 0 that exactly reproduce karcher_mean within 1e-10.
Implementations§
Source§impl JfpcaModel
impl JfpcaModel
Sourcepub fn transform(
&self,
new_curves: &FdMatrix,
) -> Result<JfpcaTransform, FdarError>
pub fn transform( &self, new_curves: &FdMatrix, ) -> Result<JfpcaTransform, FdarError>
Project new curves onto the trained joint-FPCA basis.
Aligns each new curve to the trained Karcher-mean template (does NOT
re-run a fresh Karcher mean), centers with the trained mean_q, computes
shooting vectors from the trained mean_psi, and scores via the exact
dot-product formula derived from the right singular vectors.
For training-set reproducibility at < 1e-8, use JfpcaModel::score_training
which uses the stored training alignment directly. transform re-aligns via
align_to_target which does not exactly reproduce the Karcher-mean’s
post-centered gammas; the score error is bounded by the alignment tolerance.
§Arguments
new_curves— Curves to project (n_new × m). Must have the same number of columns as the training grid (self.argvals.len()).
§Errors
Returns FdarError::InvalidDimension when:
new_curves.ncols() != self.argvals.len()(grid mismatch)n_new < 1
Sourcepub fn score_training(&self) -> Result<JfpcaTransform, FdarError>
pub fn score_training(&self) -> Result<JfpcaTransform, FdarError>
Score the training set using the stored alignment (< 1e-8 round-trip precision).
Uses JfpcaModel::training_gammas and JfpcaModel::training_aligned
directly, bypassing re-alignment. Intended for round-trip verification and
Phase 73 VEESA explainability which needs exact training coordinates.
§Errors
Returns FdarError::InvalidDimension when training_aligned or
training_gammas has an unexpected shape (should not occur on a
well-formed model, but the fields are public and may be mutated or
deserialized into an inconsistent state).
Sourcepub fn principal_directions(
&self,
pc_index: usize,
c_values: &[f64],
) -> Result<PrincipalDirections, FdarError>
pub fn principal_directions( &self, pc_index: usize, c_values: &[f64], ) -> Result<PrincipalDirections, FdarError>
Reconstruct amplitude and phase principal-direction curves (VEE-04).
For each c in c_values, perturbs the pc_index-th joint-FPCA basis direction
by c * σⱼ (where σⱼ = sqrt(eigenvalues[pc_index])) and reconstructs both the
amplitude curve (via SRSF inversion) and the phase curve (via tangent-space
exponentiation + ψ→γ conversion).
At c = 0 the amplitude curve exactly reproduces JfpcaModel::karcher_mean
within 1e-10, and the phase curve is the identity warp on argvals.
§Arguments
pc_index— 0-based PC index. Must be< self.ncomp.c_values— Multiplier values (e.g.&[-2.0, -1.0, 0.0, 1.0, 2.0]).
§Errors
FdarError::InvalidParameterifpc_index >= self.ncomporc_valuesis empty.
Trait Implementations§
Source§impl Clone for JfpcaModel
impl Clone for JfpcaModel
Source§fn clone(&self) -> JfpcaModel
fn clone(&self) -> JfpcaModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JfpcaModel
impl Debug for JfpcaModel
Source§impl PartialEq for JfpcaModel
impl PartialEq for JfpcaModel
impl StructuralPartialEq for JfpcaModel
Auto Trait Implementations§
impl Freeze for JfpcaModel
impl RefUnwindSafe for JfpcaModel
impl Send for JfpcaModel
impl Sync for JfpcaModel
impl Unpin for JfpcaModel
impl UnsafeUnpin for JfpcaModel
impl UnwindSafe for JfpcaModel
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar 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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.