Skip to content

gabrielClassificationError

function gabrielClassificationError(
hdIn,
ldIn,
labels): GceResult;

Defined in: metrics/geometric.ts:232

Class disagreements between visually adjacent points, weighted by how close they really are.

The only measure here that uses the data and the labels. Every other label-based measure sees the projection alone, so a layout that invents clean clusters fools them; this one asks whether points drawn side by side are genuinely related, and charges most for the pairs that are not.

Each point’s Gabriel neighbours are ordered by their high-dimensional distance and weighted by a harmonically decaying sequence, so the weight is largest for the neighbour that is genuinely nearest. A cross-class edge to a point the data says is close therefore costs the most; one to a point that was always far away costs least. The adjacency itself comes from the projection, so a layout that draws the classes apart has few cross-class edges to charge for at all.

  • Needs: high-dimensional data and projection. Labels required.
  • Range: [0, ∞), lower is better; 0 means no adjacent pair crosses a class boundary. Not normalised — it grows with neighbourhood size, so compare only within a dataset.
  • Needs a 2-dimensional projection: it builds a Gabriel graph, which gabrielEdges defines only for d === 2.
  • Cost: O(N log N) for the Delaunay triangulation the Gabriel graph is filtered from, plus O(N·D + Σ k log k) for the weighting — the graph is planar, so the edge count is linear in N. The exact strategy, used as a fallback when points coincide, is the O(N²) path.

Gabriel leaves have no defined weighting — the harmonic sequence divides by kj - 1 — and isolated points have no neighbours at all; both are left out of the average. counted is how many points contributed, and excluded is an Int32Array of the indices that did not. Their per-point entries are NaN, which is what localKind: "partial-mean" announces.

ParameterType
hdInPointsInput
ldInPointsInput
labelsreadonly unknown[]

GceResult

Thrun, Märte & Stier, Mach. Learn. Knowl. Extr. 5 (2023) https://doi.org/10.3390/make5030056

import { gabrielClassificationError } from "@saehrimnir/sickle";
// The only label measure that also reads the high-dimensional data; the
// projection must be 2-D.
const g = gabrielClassificationError(data, projection, labels);
g.value; // 0.2147 — unbounded, lower is better
g.counted; // 196 — points that contributed
g.excluded.length; // 4 — indices of Gabriel leaves and isolated points
g.localKind; // "partial-mean": excluded points hold NaN, not 0