nearest_label

std.geometry.nearest_label · Level L2

One-nearest-neighbour classification: the label of the point closest to q. ArgMin gives the position; a mask built from Iota reads the label there.

labels[argminⱼ ‖Pⱼ − q‖²]

Signature

nearest_label(q: f64[d], points: f64[m, d], labels: f64[m]) → f64[]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

qf64[d]pointsf64[m, d]labelsf64[m]SubtractdiffIotaposMultiplysqReduceSumdistArgMinkEqualpickMultiplychosenReduceSumlabellabelf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference labels[np.argmin(np.sum((points - q) ** 2, axis=1))] in exact rational arithmetic, on all 40 test cases.
  • All 40 float64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
100%
bit-equal to the NumPy formula in float64
98%
largest error, in units in the last place
0

Identity

Calls
—
Called by
—
sha256:56bda334dbb114b0a4f4d95c2a5bd87bc3521b9ceef514a2925d749846ceaf68

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.geometry.nearest_label · Ω:nearest_label
Pins
sha256:b5e1b13fd4acae0852cabfb47dd8349adb3758b9b85952839d25a581e2283ac5this graph alone
Evidence
sha256:86377e231b40e4493a0e9aef5997b62e61ce5d98b80c0afbe72c7e0cbe028765the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.