Treat a two-dimensional embedding as a projection of higher-dimensional records, then inspect neighbor retention, run settings and label leakage before interpreting the map.
Embedding scatterplots: audit neighborhoods before naming clusters
Separate the map from the feature space
An embedding scatterplot gives each high-dimensional record a two-dimensional position so a human can inspect local structure. The plotted axes are coordinates of a fitted projection, not physical units or original features. A short distance on the map can suggest similar records under the chosen input representation, but map distance is not automatically the original distance. Some algorithms prioritize local neighborhoods and distort separation between distant groups. Others preserve a different notion of geometry. Choose the feature representation, distance metric and preprocessing before discussing the shape of the picture. For ticket text vectors, the unit is one ticket, not a sentence fragment that slipped in during preprocessing. A plot of sampled tickets must say how the sample was selected. Visual encoding, overplotting and level of detail remain ordinary chart obligations.
Freeze a reproducible projection contract
Two maps are comparable only when they use compatible records, preprocessing, distance definitions, algorithm settings and random initialization rules. Keep a run manifest with the feature version, training population, sample IDs, projection settings and seed. A seed makes one run reproducible; it does not make every run or changed dataset geometrically identical. Do not compare the absolute X or Y coordinate across separately fitted maps. Rotation, reflection and nonlinear warping may move an otherwise similar configuration, while a changed sample can alter neighborhoods. If the user must track records over time, fit a stable reference projection where the method permits it or align maps with a declared procedure; still inspect the underlying neighbor sets. Export manifests and provenance make this distinction operational.
Check neighbors against the original vectors
The worked contract accepts already computed map coordinates and original numeric features. It does not implement a projection algorithm. For each record it finds the nearest neighbor in both spaces and counts whether the original neighbor survived the map. Ties break by stable record ID so an audit reruns predictably. The score is a compact diagnostic, not a certificate that every distance, density or group boundary is faithful. Run it at several neighborhood sizes, inspect representative failures and compare known operational slices. Standardize numeric features under a documented rule before Euclidean distance; otherwise a field measured in thousands can overwhelm one measured in fractions. If the original representation is an embedding vector, use the metric intended for that representation rather than quietly substituting Euclidean distance. Pairwise coverage and coverage summaries offer useful checks on the data before projection.
Keep labels and visual density honest
Coloring an embedding by a known category can help find errors, but those labels may also have influenced the feature vectors or preprocessing. Disclose that path before claiming independent separation. A visible island can be produced by the projection objective, sample composition or density imbalance rather than a real, well-separated class. Show group counts, a legend and a selection-to-record table; do not rely on a hover tooltip as the only way to identify outliers. When thousands of points share pixels, use opacity or density bins and keep rare groups inspectable. Compare the view with a simpler baseline and a second run configuration before acting on small islands. Density bins, keyboard selection and text alternatives help readers audit the same records.
Worked contract
from math import isfinite
def ticket_neighbor_retention(records: list[tuple[str, tuple[float, ...],
tuple[float, float]]]):
if len(records) < 3:
raise ValueError("at least three tickets are required")
ticket_ids = [ticket_id for ticket_id, _, _ in records]
feature_width = len(records[0][1])
if len(set(ticket_ids)) != len(records) or feature_width == 0:
raise ValueError("ticket IDs must be unique and vectors nonempty")
for ticket_id, features, position in records:
if (not ticket_id or len(features) != feature_width or len(position) != 2 or
any(not isinstance(value, (int, float)) or isinstance(value, bool)
or not isfinite(value) for value in (*features, *position))):
raise ValueError("all vectors and map positions must be finite")
def nearest(index: int, projected: bool):
source = records[index][2 if projected else 1]
candidates = []
for other_index, (other_id, features, position) in enumerate(records):
if other_index == index:
continue
target = position if projected else features
distance_squared = sum((left - right) ** 2
for left, right in zip(source, target))
candidates.append((distance_squared, other_id))
return min(candidates)[1]
retained = [ticket_ids[index] for index in range(len(records))
if nearest(index, False) == nearest(index, True)]
return retained, len(retained) / len(records)
support_tickets = [
("billing-47", (0.0, 0.0, 0.0), (0.0, 0.0)),
("billing-53", (0.1, 0.1, 0.1), (0.1, 0.1)),
("login-83", (3.0, 3.0, 3.0), (3.0, 3.0)),
("login-89", (3.1, 3.1, 3.1), (3.1, 3.1)),
("refund-97", (8.0, 0.0, 0.0), (0.25, 0.25)),
]
retained, share = ticket_neighbor_retention(support_tickets)
assert retained == ["billing-47", "billing-53", "login-83", "login-89"]
assert share == 0.8Performance and operating cost
For N records with D original features, the direct audit compares every ordered pair and costs O(N²D) time. It keeps only one row of distance candidates at a time, so working space is O(N) beyond the supplied vectors and map coordinates. At larger scale, audit a documented sample or use a nearest-neighbor index whose metric and approximation error are recorded. The five-ticket example retains the same nearest neighbor for four tickets. The projected refund ticket lands near a billing ticket even though its nearest neighbor in the three-feature space is a login ticket; the retention score is therefore 4/5, or 0.8. Do not interpret that single score as a probability that the map is correct. Inspect the specific mismatch before using the map to route tickets.
Common Mistakes
- Treating the two map axes as named features or comparing raw coordinates from separately fitted maps.
- Declaring an island a real cluster from spacing alone without checking original-space neighborhoods.
- Using a label to build the representation and then describing its color separation as independent validation.
- Reporting one seed, one neighborhood size and one overall retention score without inspecting failures.
- Computing original-space distances on unscaled mixed-unit features without a metric contract.
Validation drill
Project 83 support tickets from a frozen feature version. Record the sample IDs, preprocessing, metric, projection settings and seed. Audit nearest-neighbor retention for two neighborhood sizes, inspect ten failed neighbors by ticket ID, and repeat the projection with a second seed before naming any visible island.
