nerv
function nerv(p): MetricResult & { precision: number; recall: number;};Defined in: metrics/embedding.ts:148
Neighbourhood preservation framed as an information-retrieval trade-off.
Treats each point’s neighbourhood as a probability distribution and measures the
divergence between the two spaces. recall is the cost of neighbours the
projection missed; precision is the cost of neighbours it invented.
lambda chooses which matters: 1 is pure recall, 0 pure precision, 0.5 balanced.
- Needs: high-dimensional data and projection. No labels.
- Range: [0, ∞), lower is better; 0 only when the neighbourhood distributions coincide.
- Cost: O(N²·D) for its own pass, plus a bisection per point.
Reported per point rather than summed, so values are comparable across dataset sizes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
p | Nerv |
Returns
Section titled “Returns”Venna, Peltonen, Nybo, Aidos & Kaski, JMLR 11 (2010) https://www.jmlr.org/papers/v11/venna10a.html
Example
Section titled “Example”import { nervPass, nerv } from "@saehrimnir/sickle";
// nerv reads a NeRV pass, not `analyze`.const p = nervPass(data, projection, { lambda: 0.5, perplexity: 30 });
nerv(p).value; // 0.4611 — λ·recall + (1-λ)·precision, lower is betterp.recall; // 77.6049 — KL(p‖q), the SNE/t-SNE end at λ = 1p.precision; // 106.8424 — KL(q‖p), the λ = 0 end