UNPKG

als-statistics

Version:

Modular JS statistics toolkit for Node.js and the browser: descriptive stats, correlations (Pearson/Spearman/Kendall), t-tests & ANOVA (Student/Welch), reliability (Cronbach’s alpha), regression (linear/logistic), clustering (DBSCAN/HDBSCAN), and table/co

11 lines 515 B
export function buildClusters(obj) { const maxId = Math.max(...obj.labels); if (!Number.isFinite(maxId) || maxId < 1) return; for (let id = 1; id <= maxId; id++) { const clusterTable = {}; obj.samples.forEach(({ name, values }, idx) => { if (obj.labels[idx] === id) clusterTable[name] = [...values]; // Копия массива, чтобы не трогать оригинал }); if (Object.keys(clusterTable).length > 0) obj.clusters.push(clusterTable); } }