clusters
function clusters(ldIn, labels): Clusters;Defined in: metrics/separability.ts:54
Group points by label and compute the centroids the label-based measures need.
Build this once and pass it to each of them; it is the shared setup, not a measure itself.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ldIn | PointsInput |
labels | readonly unknown[] |
Returns
Section titled “Returns”Example
Section titled “Example”import { clusters, silhouette, daviesBouldin } from "@saehrimnir/sickle";
// `projection` is number[][], 200 x 2; one label per point, 4 classes.const cl = clusters(projection, labels); // build once, pass to every measure
cl.keys.length; // 4cl.sizes; // Uint32Array [50, 50, 50, 50]silhouette(projection, cl).value; // 0.8838daviesBouldin(projection, cl).value; // 0.1603