sammonStress
function sammonStress(f): MetricResult;Defined in: metrics/embedding.ts:48
Stress that weights short distances most heavily.
Dividing each pair’s error by its original distance makes local structure dominate, so this rewards projections that get neighbourhoods right even if the global layout drifts.
- Needs: high-dimensional data and projection. No labels.
- Range: [0, ∞), lower is better; 0 is exact.
- Cost: O(1), from an O(N²·D) pass.
The returned value is the normalised ratio of Sammon 1969,
Σ(d − d̂)²/d ÷ Σd, not the bare sum — dividing by Σd is what makes it
comparable across datasets of different scale and size.
Pairs at zero original distance are excluded — they would divide by zero — so duplicate points quietly shrink the denominator.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
f | EmbeddingMoments |
Returns
Section titled “Returns”Sammon, IEEE Trans. Computers C-18 (1969) https://doi.org/10.1109/T-C.1969.222678
Example
Section titled “Example”import { analyze, sammonStress } from "@saehrimnir/sickle";
const a = analyze(data, projection); // the O(N²·D) pass comes firstconst s = sammonStress(a.embedding); // read from a.embedding, not from as.value; // 0.581 for a noisy 50-point circle cut open into a lines.local[0]; // 0.013 — that point's share; s.local sums to s.value