clustering-tfjs
Version:
High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility
43 lines • 1.74 kB
TypeScript
/**
* Deterministic eigen-pair post–processing.
*
* Many numerical eigensolvers return eigenvectors in arbitrary order and with
* an arbitrary global ± sign per vector. For downstream algorithms (e.g.
* Spectral Clustering) we require a stable ordering and sign convention so
* that identical input always produces identical embeddings.
*
* The convention implemented here matches scikit-learn:
* 1. Eigen-pairs are sorted by ascending eigen-value.
* 2. For every eigen-vector the component with the largest absolute value
* is made positive by optionally multiplying the vector by −1.
*
* The function operates purely on native JavaScript arrays to avoid pulling
* TensorFlow.js into low-level utilities and reduce garbage generation.
*/
export interface EigenPairInput {
eigenvalues: number[];
eigenvectors: number[][];
}
export interface EigenPairOutput {
/**
* Eigen-values sorted in ascending order. We expose them under two
* property names to stay compatible with the acceptance criteria drafted
* in task-12.3.1 (valuesSorted) *and* with existing internal call-sites
* (eigenvalues).
*/
eigenvalues: number[];
/** Alias – kept for backwards-compatibility with task spec */
valuesSorted: number[];
/**
* Column-wise eigen-vectors after sign correction.
* Same dual naming scheme as for the eigen-values.
*/
eigenvectors: number[][];
/** Alias matching task spec wording */
vectorsSorted: number[][];
}
/**
* Applies deterministic ordering and sign convention to raw eigen-pairs.
*/
export declare function deterministic_eigenpair_processing(input: EigenPairInput): EigenPairOutput;
//# sourceMappingURL=eigen_post.d.ts.map