Skip to content

Evaluation, diagnostics, benchmarks, and additional tests · Evaluation, diagnostics, benchmarks, and additional hypothesis tests · EVA013 · Metric

Trustworthiness and continuity

Evaluate local-neighbor distortions introduced by dimensionality reduction.

Partly runs in CodeSplash Complete calculation CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method covers part of this entry; some options or variants aren't built yet.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Partly runs in CodeSplash
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through discover.autoencoder, discover.contrastive, discover.manifold. The reference's example ran here in one language.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Evaluate local-neighbor distortions introduced by dimensionality reduction.

Question / hypotheses

Are low-dimensional neighbors genuine original-space neighbors, and are original neighbors preserved?

Architecture / computational structure

A fixed scoring/calibration pipeline applied to model outputs or supplied observations; the formula and usage sections identify its operations.

Assumptions

Original-space distance must be meaningful; align observations and define tie handling. Neighbor count k must meet the normalization conditions, commonly k<n/2.

Formula / computational definition

T(k)=1−2∑i∑j∈Uk(i)(r(i,j)−k)nk(2n−3k−1).T(k)=1-\frac{2\sum_i\sum_{j\in U_k(i)}(r(i,j)-k)}{nk(2n-3k-1)}.

Parameters and notation

U_k(i) contains neighbors appearing only in the embedding; r(i,j) is original rank. Continuity reverses original and embedded roles. k and distance are evaluation hyperparameters.

Fitting, fine-tuning, and adaptation

There is no model fine-tuning step for this evaluation procedure. Freeze the evaluated systems and evaluator before the final test. Select evaluation settings on development data; if a learned evaluator or calibration model is adapted, use separate fitting data, version it, and reassess its validity.

How to use and calibrate

Plot both curves across several neighborhood sizes. Evaluate the fitted embedding on held-out points when out-of-sample mapping is available and compare with a simple PCA baseline.

Example application

Check whether a UMAP visualization creates attractive but misleading local islands.

Interpretation / pitfalls

Watch out

High local fidelity does not establish global distance or density preservation. Comparing embeddings after choosing k to favor one is a form of evaluation tuning.

Python and R code examples

Scope: Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.

Validation: Python — Executed successfully on synthetic inputs. R — reviewed but not executed in this environment. Python dependencies are explicit imports; R uses base R unless a package/bridge is explicitly named.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs numpy, sklearn

import numpy as np
from sklearn.manifold import trustworthiness
X=np.arange(30.).reshape(10,3); Z=X[:,:1]
print(trustworthiness(X,Z,n_neighbors=3),trustworthiness(Z,X,n_neighbors=3))
R

Bridge to another language — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs reticulate

# Bridge to identical rank and tie conventions.
m <- reticulate::import("sklearn.manifold"); X <- matrix(0:29,nrow=10,byrow=TRUE); Z <- X[,1,drop=FALSE]
print(m$trustworthiness(X,Z,n_neighbors=3L)); print(m$trustworthiness(Z,X,n_neighbors=3L))

Sources

From the CodeSplash reference, entry EVA013.