classificationError
function classificationError( ldIn, labels, k?, knn?): MetricResult;Defined in: metrics/labelled.ts:132
Share of points whose label is not the majority among their visual neighbours.
The decision-rule counterpart of neighborhoodHit: it asks whether a viewer reading the plot would guess right, rather than how mixed the neighbourhood is.
- Needs: projection only. Labels required.
- Range: [0, 1], lower is better.
- Cost: O(N²·D).
k defaults to 20. Ties count as correct — a tie means the picture is
genuinely ambiguous there — so the rule reads slightly optimistically.
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”Example
Section titled “Example”import { classificationError } from "@saehrimnir/sickle";
// k-NN misclassification rate, k = 20 by default. Ties count as correct, so// this reads slightly optimistically.classificationError(projection, labels).value; // 0 — lower is better