Skip to main content

JfpcaModel

Struct JfpcaModel 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: FdMatrix

Vertical (amplitude) eigenvector component (ncomp × (m+1)).

Rows are the amplitude rows of the joint right-singular vectors V^T.

§horiz_component: FdMatrix

Horizontal (phase) eigenvector component (ncomp × m).

Rows are the phase rows of the joint right-singular vectors V^T.

§balance_c: f64

Phase-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: usize

Number of principal components (clamped to n-1 at training time).

§joint_result: JointFpcaResult

Full joint FPCA result from training (contains training scores).

§lambda: f64

Warp penalty weight used at training time.

Stored so the transform step can reproduce the same alignment geodesic.

§training_gammas: FdMatrix

Warping 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: FdMatrix

Training 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

Source

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
Source

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).

Source

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

Trait Implementations§

Source§

impl Clone for JfpcaModel

Source§

fn clone(&self) -> JfpcaModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JfpcaModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for JfpcaModel

Source§

fn eq(&self, other: &JfpcaModel) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for JfpcaModel

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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