Skip to content

hypothesisMargin

function hypothesisMargin(ldIn, cl): MetricResult;

Defined in: metrics/separability.ts:361

Average gap between each point’s nearest same-class and nearest other-class neighbour.

Unlike centroid measures this is purely local, so it copes with classes of any shape. Its units are those of the projection, so compare only within a dataset.

  • Needs: projection only. Labels required.
  • Range: (-∞, ∞), higher is better. Negative means the typical point is closer to another class than to its own.
  • Cost: O(N²·D).

Points whose class has no other member are skipped. When that happens the whole local array is rescaled by (value * n) / sum(local) so that it still averages to the score, as localKind: "mean" promises — which means an individual entry is no longer exactly that point’s miss-minus-hit margin. With every class populated, no rescaling occurs and the entries are the raw margins.

Per-point values average to the score.

ParameterType
ldInPointsInput
clClusters

MetricResult

Gilad-Bachrach, Navot & Tishby, ICML 2004 https://doi.org/10.1145/1015330.1015352

import { clusters, hypothesisMargin } from "@saehrimnir/sickle";
const cl = clusters(projection, labels);
hypothesisMargin(projection, cl).value; // 12.494 — unbounded in both directions