clustering-tfjs
Version:
High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility
29 lines • 1.25 kB
TypeScript
import { DataMatrix, LabelVector } from '../clustering/types';
/**
* Computes the Davies-Bouldin score.
*
* The Davies-Bouldin index is defined as the average similarity measure
* of each cluster with its most similar cluster. Lower values indicate
* better clustering (clusters are more separated).
*
* Formula: DB = (1/k) * sum(max_{i≠j}(R_{ij}))
* where R_{ij} = (s_i + s_j) / d_{ij}
* - s_i = average distance from points in cluster i to its centroid
* - d_{ij} = distance between centroids of clusters i and j
*
* @param X - Data matrix of shape [n_samples, n_features]
* @param labels - Cluster labels for each sample
* @returns The Davies-Bouldin score (lower is better)
* @throws Error if k <= 1
*/
export declare function daviesBouldin(X: DataMatrix, labels: LabelVector): number;
/**
* Computes the Davies-Bouldin score with optimized memory usage.
* This version minimizes tensor allocations and disposals.
*
* @param X - Data matrix of shape [n_samples, n_features]
* @param labels - Cluster labels for each sample
* @returns The Davies-Bouldin score (lower is better)
*/
export declare function daviesBouldinEfficient(X: DataMatrix, labels: LabelVector): number;
//# sourceMappingURL=davies_bouldin.d.ts.map