pub fn compute_pca_2d(embeddings: &[Vec<f32>]) -> Vec<(f32, f32)>Expand description
Project a set of embeddings into 2D coordinates via PCA.
Inputs can be heterogeneous (sparse, dense, varying dimensions). They are unified by their term-set union so the math stays valid.
Returns one (x, y) per input, in the same order. Returns an empty
vector when embeddings is empty. All-zero or single-entry inputs
are returned at the origin (0, 0).
Complexity: O(nnz · iterations · k) where nnz is the number of
non-zero entries across all input rows. The kernel’s TF-IDF vectors
are typically sparse (a few non-zero terms per entry), so the
practical cost is far below the dense O(n · d) bound.