neighborhoodHit
function neighborhoodHit( ldIn, labels, k?, knn?): MetricResult;Defined in: metrics/labelled.ts:88
Share of each point’s visual neighbours that carry its own label.
Answers “if I look at a point and the ones drawn around it, do they agree?” — close to how a viewer actually reads a coloured scatterplot.
- Needs: projection only. Labels required.
- Range: [0, 1], higher is better. The chance level is the largest class’s share of the data, not 0.
- Cost: O(N²·D).
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
ldIn | PointsInput | undefined |
labels | readonly unknown[] | undefined |
k | number | 20 |
knn? | Int32Array<ArrayBufferLike> | undefined |
Returns
Section titled “Returns”Paulovich et al., IEEE TVCG 14 (2008) https://doi.org/10.1109/TVCG.2007.70443
Example
Section titled “Example”import { neighborhoodHit } from "@saehrimnir/sickle";
// Takes raw labels, not a Clusters object.neighborhoodHit(projection, labels, 20).value; // 1 — every neighbour shares a class// Chance here is the largest class's share, not 0.