UNPKG

clustering-tfjs

Version:

High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility

28 lines 1.3 kB
import type { BaseClustering, DataMatrix, LabelVector, KMeansParams } from './types'; import * as tf from '../tf-adapter'; /** * Extremely lightweight – yet reasonably efficient – K-Means implementation * intended solely as an internal helper for SpectralClustering. * * The class purposefully **does not** try to match the full scikit-learn API * but merely exposes the minimal surface required by downstream tasks. */ export declare class KMeans implements BaseClustering<KMeansParams> { readonly params: KMeansParams; /** Lazily populated labels after calling {@link fit}. */ labels_: LabelVector | null; /** Final cluster centroids (shape: nClusters × nFeatures). */ centroids_: tf.Tensor2D | null; /** Final value of the inertia criterion (sum of squared distances). */ inertia_: number | null; private static readonly DEFAULT_MAX_ITER; private static readonly DEFAULT_TOL; private static readonly DEFAULT_N_INIT; constructor(params: KMeansParams); /** Provides deterministic or non-deterministic random stream aligned with NumPy. */ private static makeRandomStream; private static validateParams; fit(X: DataMatrix): Promise<void>; fitPredict(X: DataMatrix): Promise<LabelVector>; } //# sourceMappingURL=kmeans.d.ts.map