UNPKG

clustering-tfjs

Version:

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

30 lines 1.28 kB
import { DataMatrix, LabelVector } from '../clustering/types'; /** * Computes the Calinski-Harabasz score (also known as Variance Ratio Criterion). * * The score is defined as the ratio of the between-cluster dispersion to the * within-cluster dispersion. Higher values indicate better-defined clusters. * * Formula: CH = (BSS / (k - 1)) / (WSS / (n - k)) * where: * - BSS = between-cluster sum of squares * - WSS = within-cluster sum of squares * - k = number of clusters * - n = number of samples * * @param X - Data matrix of shape [n_samples, n_features] * @param labels - Cluster labels for each sample * @returns The Calinski-Harabasz score (higher is better) * @throws Error if k <= 1 or k >= n_samples */ export declare function calinskiHarabasz(X: DataMatrix, labels: LabelVector): number; /** * Computes the Calinski-Harabasz score in a memory-efficient manner for large datasets. * This version processes clusters sequentially to minimize memory usage. * * @param X - Data matrix of shape [n_samples, n_features] * @param labels - Cluster labels for each sample * @returns The Calinski-Harabasz score */ export declare function calinskiHarabaszEfficient(X: DataMatrix, labels: LabelVector): number; //# sourceMappingURL=calinski_harabasz.d.ts.map