pub struct PcaProjection { /* private fields */ }Expand description
Corpus-fitted projection via spherical PCA.
Finds the 3 principal directions of maximum angular variance in the embedding space, then projects new embeddings onto them. This preserves angular (cosine similarity) relationships as faithfully as possible in 3 dimensions.
Fitting: O(N·n·k·iters) where N=corpus size, n=dimension, k=3. Projection: O(n) per embedding.
Implementations§
Source§impl PcaProjection
impl PcaProjection
pub fn fit(embeddings: &[Embedding], radial: RadialStrategy) -> Self
pub fn fit_default(embeddings: &[Embedding]) -> Self
Sourcepub fn with_volumetric(self, enabled: bool) -> Self
pub fn with_volumetric(self, enabled: bool) -> Self
Enable volumetric mode: r comes from the PCA projection magnitude instead of the embedding magnitude. Points distribute through the full 3D volume rather than clustering on the sphere surface.
Sourcepub fn explained_variance_ratio(&self) -> f64
pub fn explained_variance_ratio(&self) -> f64
The fraction of total variance captured by the top-3 PCA components. A global quality metric for the projection — higher means less information lost.
Trait Implementations§
Source§impl Clone for PcaProjection
impl Clone for PcaProjection
Source§fn clone(&self) -> PcaProjection
fn clone(&self) -> PcaProjection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Projection for PcaProjection
impl Projection for PcaProjection
fn project(&self, embedding: &Embedding) -> SphericalPoint
Source§fn project_rich(&self, embedding: &Embedding) -> ProjectedPoint
fn project_rich(&self, embedding: &Embedding) -> ProjectedPoint
Project with rich metadata: certainty, intensity, projection magnitude.
fn dimensionality(&self) -> usize
Auto Trait Implementations§
impl Freeze for PcaProjection
impl !RefUnwindSafe for PcaProjection
impl Send for PcaProjection
impl Sync for PcaProjection
impl Unpin for PcaProjection
impl UnsafeUnpin for PcaProjection
impl !UnwindSafe for PcaProjection
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