Distance Metrics and Similarity Measures

Imagine handing an algorithm ten thousand customer records. It must find natural groups within them. Before any clustering algorithm can run, something more basic must be settled. What does it mean for two customers to be "close"? Every unsupervised method — K-Means Clustering, Hierarchical Clustering, DBSCAN and Density-Based Clustering — inherits its entire notion of structure from one upstream choice: the distance or similarity function. This choice is not a minor implementation detail. It is the silent assumption baked into every cluster boundary. It underlies every dendrogram split and every density estimate. Two datasets with identical points can produce entirely different clusterings. This depends only on how distance is measured. It might be straight-line Euclidean distance, city-block Manhattan distance, angular cosine similarity, or covariance-aware Mahalanobis distance. Choosing wrong does not throw an error. It silently returns confident, plausible-looking, wrong answers. This article builds a rigorous vocabulary for "closeness." We define distance metrics formally, and state the axioms that make a function a true metric. We walk through the four workhorses of unsupervised learning: Euclidean, Manhattan, cosine, and Mahalanobis distance. We show geometrically how each one warps the notion of a "ball" of nearby points. We explain why that shape directly determines the clusters an algorithm will find. By the end, you will be able to look at a dataset — its scale, its dimensionality, its correlation structure. You will be able to reason about which distance measure produces sensible clusters versus which produces nonsense. This groundwork is a direct prerequisite for understanding several key ideas. It explains why k-means prefers spherical clusters. It explains why hierarchical linkage choices matter. It also explains why density-based methods need a carefully calibrated neighborhood radius.

Key takeaways
  • A distance metric formalizes "closeness"; it must satisfy non-negativity, identity, symmetry, and the triangle inequality.
  • Euclidean distance measures straight-line distance; it is rotation-invariant but sensitive to feature scale.
  • Manhattan distance sums absolute coordinate differences; it is more robust to outliers and high dimensions.
  • Cosine similarity measures the angle between vectors, ignoring magnitude — ideal for text and sparse high-dimensional data.
  • Mahalanobis distance rescales space by the data's covariance, correcting for correlated and differently-scaled features.
  • The distance function chosen implicitly defines the shape of clusters an algorithm can ever discover.
The core insight

Every clustering algorithm only "sees" the data through its distance function, so the distance metric — not the algorithm — is what actually defines cluster structure.

The idea

A distance metric is a function d:X×X→R≥0d: X \times X \to \mathbb{R}_{\ge 0} that quantifies dissimilarity between two points in a space XX. For dd to qualify as a true metric, it must satisfy four axioms for all points x,y,zx, y, z:

d(x,y)≥0,d(x,y)=0  ⟺  x=yd(x,y) \ge 0, \qquad d(x,y)=0 \iff x=y
d(x,y)=d(y,x)(symmetry)d(x,y) = d(y,x) \quad \text{(symmetry)}
d(x,z)≤d(x,y)+d(y,z)(triangle inequality)d(x,z) \le d(x,y) + d(y,z) \quad \text{(triangle inequality)}

The triangle inequality is the deepest of these: it guarantees that distances behave consistently, so that "if xx is near yy and yy is near zz, then xx cannot be too far from zz." Algorithms that exploit spatial pruning (like ball-trees or DBSCAN's neighborhood queries) rely on this property for both correctness and speed. A similarity measure, by contrast, increases as points become more alike rather than less. Cosine similarity is the canonical example — it is not a metric in the strict sense (it fails the identity and triangle-inequality axioms without transformation), yet it is one of the most widely used comparison functions in high-dimensional and text-based unsupervised learning. Similarity and distance are convertible: d=1−sd = 1 - s or d=2(1−s)d = \sqrt{2(1-s)} are common conversions when a similarity score needs to be plugged into a distance-based algorithm. The choice between these functions encodes an assumption about what "shape" of neighborhood matters. Euclidean distance treats all directions equally, producing spherical neighborhoods. Manhattan distance moves only along axes, producing diamond-shaped neighborhoods. Cosine similarity discards magnitude entirely, comparing only orientation. Mahalanobis distance stretches and rotates space according to feature covariance, producing ellipsoidal neighborhoods aligned with the data's own correlation structure. Every clustering algorithm downstream inherits exactly this geometry.

How it works

The four core measures

Euclidean distance (also L2L_2 distance) between vectors x,y∈Rnx, y \in \mathbb{R}^n:

dE(x,y)=∑i=1n(xi−yi)2d_E(x,y) = \sqrt{\sum_{i=1}^n (x_i - y_i)^2}

This is straight-line distance — the generalization of the Pythagorean theorem to nn dimensions. It is the default assumption behind k-means, which minimizes total squared Euclidean distance to cluster centroids.

Manhattan distance (also L1L_1 or "city-block" distance):

dM(x,y)=∑i=1n∣xi−yi∣d_M(x,y) = \sum_{i=1}^n |x_i - y_i|

This measures distance as if movement were restricted to a grid of streets (hence "city block"). It grows linearly rather than quadratically with per-coordinate deviation, making it less sensitive to a single large discrepancy — a useful robustness property when data has outliers or heavy-tailed noise.

Cosine similarity measures the angle θ\theta between two vectors, ignoring their length:

cos⁡(θ)=x⋅y∥x∥ ∥y∥=∑ixiyi∑ixi2∑iyi2\cos(\theta) = \frac{x \cdot y}{\|x\|\, \|y\|} = \frac{\sum_i x_i y_i}{\sqrt{\sum_i x_i^2}\sqrt{\sum_i y_i^2}}

Cosine similarity ranges over [−1,1][-1, 1] (or [0,1][0,1] for non-negative data like word counts). A common cosine distance is dcos⁡(x,y)=1−cos⁡(θ)d_{\cos}(x,y) = 1 - \cos(\theta). This measure is preferred for text documents represented as word-frequency vectors, where document length (magnitude) is irrelevant but topical direction is what matters.

Mahalanobis distance incorporates the covariance structure Σ\Sigma of the data:

dMah(x,y)=(x−y)⊤Σ−1(x−y)d_{\text{Mah}}(x,y) = \sqrt{(x-y)^\top \Sigma^{-1} (x-y)}

When Σ\Sigma is the identity matrix, this reduces exactly to Euclidean distance. When features are correlated or on different scales, Σ−1\Sigma^{-1} rescales and rotates the space so that one unit of Mahalanobis distance corresponds to one standard deviation along every direction, including diagonal directions defined by correlated features.

Step-by-step procedure for choosing and applying a metric

``` ALGORITHM: SelectAndApplyDistanceMetric INPUT: data matrix X (n points × d features), metric choice M OUTPUT: pairwise distance matrix D (n × n) 1. Inspect feature scales. IF features have very different units/ranges: standardize X (zero mean, unit variance per feature) OR use Mahalanobis distance with covariance estimated from X 2. Inspect feature correlation. IF features are strongly correlated: prefer Mahalanobis distance compute Sigma = Covariance(X) compute Sigma_inv = Inverse(Sigma) // or pseudo-inverse if singular 3. Inspect data semantics. IF data is sparse / high-dimensional (e.g. text, TF-IDF vectors): prefer cosine distance: d(x,y) = 1 - dot(x,y) / (norm(x) norm(y)) ELSE IF outliers/robustness matter: prefer Manhattan distance ELSE: default to Euclidean distance 4. Compute pairwise distances: FOR i in 1..n: FOR j in i+1..n: SWITCH M: CASE Euclidean: D[i][j] = sqrt(sum((X[i]-X[j])^2)) CASE Manhattan: D[i][j] = sum(abs(X[i]-X[j])) CASE Cosine: D[i][j] = 1 - dot(X[i],X[j]) / (norm(X[i])norm(X[j])) CASE Mahalanobis: diff = X[i]-X[j] D[i][j] = sqrt(diff^T Sigma_inv diff) D[j][i] = D[i][j] // symmetry D[i][i] = 0 for all i // identity 5. RETURN D ``` The algorithm is intentionally simple — the intellectual work happens in steps 1–3, the diagnosis of the data, not step 4, the arithmetic. This mirrors real practice: choosing the metric is a modeling decision, not a computational one.

Figure
Unit "balls" under different metrics: the same radius produces different neighborhood shapes
Euclidean (L2) circle Manhattan (L1) diamond Mahalanobis tilted ellipse Cosine angle only Same "radius", different notions of nearby

The picture is the entire point: k-means with Euclidean distance can only ever discover circular (spherical, in higher dimensions) clusters, because its notion of "close" is a circle. Feed it elongated or correlated clusters and it will slice them incorrectly. Mahalanobis distance fixes exactly this failure by letting the "ball" become an ellipse aligned with the true covariance of the data.

Complexity & correctness

Time complexity. Computing a single Euclidean, Manhattan, or cosine distance between two dd-dimensional vectors takes O(d)O(d) time — one pass over the coordinates. Computing the full pairwise distance matrix for nn points takes O(n2d)O(n^2 d) time, since there are O(n2)O(n^2) pairs. This is unavoidable if all pairwise distances are genuinely required, though many algorithms (e.g., DBSCAN with spatial indexing) avoid materializing the full matrix by using k-d trees or ball-trees, reducing effective query cost to O(log⁡n)O(\log n) per neighbor lookup in favorable dimensions. Mahalanobis distance is more expensive per pair: computing (x−y)⊤Σ−1(x−y)(x-y)^\top \Sigma^{-1}(x-y) naively costs O(d2)O(d^2) because of the matrix-vector product, and the one-time cost of inverting the d×dd \times d covariance matrix is O(d3)O(d^3) (or O(d2.37)O(d^{2.37}) with fast matrix multiplication, though this is rarely used in practice). For the full pairwise matrix this gives O(n2d2+d3)O(n^2 d^2 + d^3). In practice, one instead computes the Cholesky factor Σ−1=LL⊤\Sigma^{-1} = L L^\top once (O(d3)O(d^3)) and transforms all points via x′=L⊤xx' = L^\top x (O(nd2)O(nd^2) total), after which ordinary Euclidean distance in the transformed space reproduces Mahalanobis distance in O(n2d)O(n^2 d) — the standard efficient implementation.

Space complexity. Storing the full pairwise distance matrix requires O(n2)O(n^2) space, which becomes prohibitive for large nn (a million points would need 101210^{12} entries). Most production systems avoid this by computing distances on demand or using approximate nearest-neighbor structures.

Correctness — verifying the metric axioms. Euclidean and Manhattan distance are both instances of the general Minkowski distance family:

dp(x,y)=(∑i∣xi−yi∣p)1/pd_p(x,y) = \left(\sum_i |x_i - y_i|^p\right)^{1/p}

with p=2p=2 giving Euclidean and p=1p=1 giving Manhattan. The triangle inequality for this family is exactly Minkowski's inequality, a classical result in real analysis valid for all p≥1p \ge 1:

∥x+y∥p≤∥x∥p+∥y∥p\|x+y\|_p \le \|x\|_p + \|y\|_p

Substituting u=x−yu = x - y, v=y−zv = y - z gives dp(x,z)=∥u+v∥p≤∥u∥p+∥v∥p=dp(x,y)+dp(y,z)d_p(x,z) = \|u+v\|_p \le \|u\|_p + \|v\|_p = d_p(x,y) + d_p(y,z), confirming the triangle inequality holds. Non-negativity, identity, and symmetry follow directly from the definition of absolute value and the even power in the p=2p=2 case. Both are therefore bona fide metrics. Cosine distance is not a true metric in general. Consider three unit vectors where cos⁡(θ)\cos(\theta) can produce a violation of the triangle inequality in edge cases involving negative similarity; more fundamentally, cosine similarity itself is scale-invariant (cos⁡\cos of xx and 2x2x is 11, meaning dcos⁡=0d_{\cos}=0 for distinct vectors), which directly violates the identity axiom (d(x,y)=0d(x,y)=0 should imply x=yx=y). This is a deliberate and useful design choice: for text and embedding vectors, the magnitude is often an artifact of document length or normalization, and discarding it is exactly the point. The angular distance dθ=arccos⁡(cos⁡(θ))/πd_\theta = \arccos(\cos(\theta))/\pi is a true metric (it does satisfy the triangle inequality since it is proportional to true angular separation on the unit sphere) and is used when metric guarantees are required alongside cosine-style comparison. Mahalanobis distance is a true metric whenever Σ\Sigma is symmetric positive definite. This follows because dMah(x,y)=∥L⊤(x−y)∥2d_{\text{Mah}}(x,y) = \|L^\top(x - y)\|_2 for LL the Cholesky factor of Σ−1\Sigma^{-1} — i.e., it is exactly Euclidean distance after a fixed linear transformation. Since Euclidean distance is a metric and linear transformations preserve the triangle inequality (it is inherited via the transformed vectors), Mahalanobis distance inherits all four metric axioms directly.

Why this all matters for clustering correctness. k-means minimizes within-cluster sum of squared Euclidean distances; its convergence proof (monotonic decrease of the objective, guaranteed by Lloyd's algorithm) is specific to the Euclidean case. Using cosine similarity inside a naive k-means loop breaks this convergence guarantee unless the algorithm is adapted (spherical k-means normalizes centroids at each step to restore a valid objective). This is a direct, concrete instance of why the distance function is not swappable without re-examining the algorithm's correctness proof.

Worked example

Consider four two-dimensional points representing customers by (annual spend in thousands, visits per year), before any standardization:

PointSpend ($k)Visits
A102
B1250
C2003
D20548

Naively, spend dominates because its scale (10–205) dwarfs visits (2–50). Compute Euclidean distance dE(A,B)d_E(A,B):

dE(A,B)=(12−10)2+(50−2)2=4+2304=2308≈48.04d_E(A,B) = \sqrt{(12-10)^2 + (50-2)^2} = \sqrt{4 + 2304} = \sqrt{2308} \approx 48.04
dE(A,C)=(200−10)2+(3−2)2=36100+1≈190.0d_E(A,C) = \sqrt{(200-10)^2 + (3-2)^2} = \sqrt{36100 + 1} \approx 190.0

Under raw Euclidean distance, AA and BB (very different visit behavior, similar spend) look far closer to AA and CC (identical visit behavior, wildly different spend) — yet dE(A,B)≈48d_E(A,B) \approx 48 is much smaller than dE(A,C)≈190d_E(A,C)\approx 190, meaning Euclidean distance says AA is closer to BB. That may or may not match intuition, but the danger is scale dominance: visits (range ~48) is contributing almost the entire distance value while spend differences of 190 units barely register relative to it in some comparisons. Let's check the full matrix to see the distortion clearly.

PairEuclidean dEd_EManhattan dMd_M
A–B48.0450.0
A–C190.0191.0
A–D199.1241.0
B–C190.4235.0
B–D193.1191.0
C–D45.150.0

Here the pattern actually survives: {A,B}\{A,B\} and {C,D}\{C,D\} both cluster tightly (distances ~45–50) while cross-pairs are ~190–240, because the visits feature happens to separate the two true groups cleanly. But this is a fragile coincidence of the numbers chosen — in general, when one feature's scale dwarfs another's, Euclidean distance is dictated almost entirely by the large-scale feature, silently discarding the other feature's information. The standard fix (step 1 of the algorithm above) is standardization: rescale each feature to zero mean and unit variance before computing distance, so both features contribute comparably. Now consider a text-clustering scenario, where two documents are represented as term-frequency vectors over the vocabulary {data, model, cook}:

Documentdatamodelcook
Doc 1 (short abstract)110
Doc 2 (long paper, same topic)440
Doc 3 (unrelated recipe)003

Euclidean distance between Doc 1 and Doc 2:

dE(Doc1,Doc2)=(1−4)2+(1−4)2+02=18≈4.24d_E(\text{Doc1}, \text{Doc2}) = \sqrt{(1-4)^2+(1-4)^2+0^2} = \sqrt{18} \approx 4.24

Euclidean distance between Doc 1 and Doc 3:

dE(Doc1,Doc3)=12+12+32=11≈3.32d_E(\text{Doc1}, \text{Doc3}) = \sqrt{1^2+1^2+3^2} = \sqrt{11} \approx 3.32

Euclidean distance incorrectly says Doc 1 is closer to the unrelated recipe (Doc 3) than to the topically identical, merely longer, Doc 2 — purely an artifact of document length. Now compute cosine similarity:

cos⁡(Doc1,Doc2)=(1)(4)+(1)(4)+(0)(0)2⋅32=88=1.0\cos(\text{Doc1},\text{Doc2}) = \frac{(1)(4)+(1)(4)+(0)(0)}{\sqrt{2}\cdot\sqrt{32}} = \frac{8}{8} = 1.0
cos⁡(Doc1,Doc3)=02⋅3=0\cos(\text{Doc1},\text{Doc3}) = \frac{0}{\sqrt{2}\cdot 3} = 0

Cosine similarity correctly identifies Doc 1 and Doc 2 as identical in direction (same topic, different length) and Doc 3 as completely orthogonal (unrelated topic) — exactly the behavior wanted for text clustering, and exactly why cosine distance (1−cos⁡1-\cos) is standard for document and embedding similarity.

Common pitfalls & traps

PitfallWhy it happensConsequence
Skipping feature standardization before Euclidean distanceFeatures on different scales (e.g., income vs. age)Large-scale feature dominates entirely; small-scale features become invisible
Using cosine similarity as if it were a metric in algorithms requiring triangle inequalityCosine similarity fails the identity axiom under scalingSpatial index structures (k-d trees, ball trees) built assuming metric properties give wrong nearest neighbors
Applying Mahalanobis distance with a singular or near-singular covariance matrixHighly correlated or duplicate features make Σ\Sigma non-invertibleΣ−1\Sigma^{-1} blows up numerically; use pseudo-inverse or regularize Σ+ϵI\Sigma + \epsilon I
Ignoring the curse of dimensionalityIn high dimensions, Euclidean distances between all pairs concentrate toward similar values"Nearest" and "farthest" neighbor become nearly indistinguishable, weakening all distance-based clustering
Using Manhattan distance as a default without justificationHabit / copying code without reasoning about feature semanticsLoses robustness benefits or under/over-weights features versus what the data actually needs
Computing full n×nn \times n distance matrix for large nnNot anticipating memory costO(n2)O(n^2) memory exhausts RAM for datasets beyond a few tens of thousands of points

Pioneers & history

Origins · 1 minHermann Minkowski and how this was discovered
HM
Hermann Minkowski
1864–1909 · Mathematical physicist and geometer at Göttingen

Minkowski generalized the notion of distance beyond the familiar Euclidean case, formalizing the LpL_p norm family that unifies Euclidean and Manhattan distance as special cases (p=2p=2 and p=1p=1 respectively). His broader work on the geometry of numbers and, later, the spacetime formalism underlying special relativity, established the rigorous mathematical language of "distance" and "norm" that unsupervised learning still uses directly today.

History
1908
— Minkowski formalizes the LpL_p norm family, unifying Euclidean and Manhattan distance under one mathematical framework.
1936
— Prasanta Chandra Mahalanobis introduces the Mahalanobis distance to compare anthropometric measurements across populations with correlated features.
1957
— Stuart Lloyd develops the algorithm now known as k-means, built directly on squared Euclidean distance minimization.
1975
— Cosine similarity becomes standard in information retrieval following Gerard Salton's vector space model for document comparison.
1996
— DBSCAN formalizes density-based clustering using an explicit epsilon-radius distance threshold, generalizing across metric choices.

Prasanta Chandra Mahalanobis, an Indian statistician and founder of the Indian Statistical Institute, developed his eponymous distance in 1936 to compare skull measurements across human populations — a problem where raw Euclidean distance failed because measurements like skull length and width were highly correlated. His insight, that distance should be measured relative to the data's own covariance rather than assuming independent, equally-scaled axes, remains the conceptual core of Mahalanobis distance in modern machine learning: from anomaly detection to Gaussian mixture models, where cluster membership probability is directly governed by Mahalanobis distance to each component's mean.

Where this matters

Distance metrics are the invisible substrate beneath nearly all unsupervised and semi-supervised systems. Recommendation engines compute cosine similarity between user or item embedding vectors to find "similar" products, since embedding magnitude often reflects popularity rather than meaning. Anomaly and fraud detection systems use Mahalanobis distance to flag transactions that deviate from the correlated structure of normal spending patterns, catching outliers invisible to naive Euclidean thresholds. Search engines and vector databases (used for retrieval-augmented generation in modern language model pipelines) index embeddings using cosine or Euclidean distance depending on how the embedding model was trained and normalized. Image and signal processing pipelines frequently choose Manhattan distance for robustness against sensor noise and outlier pixels. Genomics and bioinformatics use Mahalanobis-style covariance-aware distances when comparing gene expression profiles with strongly correlated features. Every one of these systems ultimately calls into the same handful of primitives described here, and every downstream clustering method — k-means's spherical assumption, hierarchical clustering's linkage criteria, DBSCAN's epsilon-neighborhoods — is a direct consequence of the distance function chosen at this foundational layer.

Ask the tutor: How does the choice between Euclidean and Mahalanobis distance change the shape of clusters found by a Gaussian mixture model?

Is Manhattan distance always more robust than Euclidean distance?

Generally, yes, in the specific sense that it grows linearly rather than quadratically with per-coordinate error, so a single large outlier deviation contributes less relative weight to the total distance. This makes Manhattan distance a common choice when data contains occasional large errors or heavy-tailed noise. However, "more robust" does not mean "always better" — Euclidean distance's rotational invariance (distance is unchanged if you rotate the coordinate axes) is a valuable property Manhattan distance lacks, since Manhattan distance depends on the specific choice of axes. The right choice depends on whether your features have a meaningful, fixed coordinate system or could be arbitrarily rotated.

Why isn't cosine similarity considered a true distance metric?

Cosine similarity is scale-invariant: scaling a vector by any positive constant leaves its cosine similarity to other vectors unchanged. This directly violates the identity axiom of a metric, which requires that distance be zero only when two points are exactly equal — under cosine distance, a vector and any positive scalar multiple of it have distance zero despite being different points. In practice this is a feature, not a bug, for tasks like text similarity where document length shouldn't matter. If strict metric properties are needed, use the related angular distance arccos⁡(cos⁡θ)/π\arccos(\cos\theta)/\pi, which does satisfy all four axioms.

When should I use Mahalanobis distance instead of Euclidean distance?

Use Mahalanobis distance whenever your features are correlated or measured on very different scales, and you don't want to lose information by naively standardizing each feature independently (which ignores cross-feature correlation). Mahalanobis distance is especially valuable in anomaly detection and Gaussian mixture model clustering, where "unusual" should be defined relative to the data's actual covariance structure rather than raw coordinate distance. Its main costs are computational (inverting a covariance matrix) and statistical (the covariance estimate itself can be noisy or singular in high dimensions or with few samples), which is why regularized or shrinkage estimators of Σ\Sigma are often used in practice.

How does the choice of distance metric affect what clusters k-means or DBSCAN can find?

The distance metric defines the shape of the "neighborhood" or "closeness region" the algorithm reasons about, which directly constrains the shapes of clusters it can discover. Standard k-means with Euclidean distance implicitly assumes clusters are roughly spherical and similarly sized, because it minimizes squared Euclidean distance to a centroid. DBSCAN's epsilon-radius neighborhoods inherit whatever geometric shape the chosen metric imposes — circular under Euclidean, diamond-shaped under Manhattan, ellipsoidal under Mahalanobis. If the true clusters in your data are elongated or differently scaled along different axes, Euclidean-based methods will systematically misclassify points near cluster boundaries.

What is the curse of dimensionality and how does it affect distance metrics?

As the number of features grows, a well-known and counterintuitive phenomenon emerges: distances between all pairs of points tend to concentrate around similar values, so the ratio between the nearest and farthest neighbor's distance approaches 1. This means "nearness" becomes statistically less meaningful in very high-dimensional spaces, weakening any distance-based clustering or nearest-neighbor method. Mitigations include dimensionality reduction (e.g., PCA) before clustering, using cosine similarity (which is less prone to this concentration effect for sparse high-dimensional data), or using metrics tailored to the true intrinsic dimensionality of the data.

Can I convert between similarity scores and distance scores?

Yes, and this is common practice. If s(x,y)∈[0,1]s(x,y) \in [0,1] is a similarity score (like cosine similarity rescaled to be non-negative), a valid distance can often be derived, such as d(x,y)=1−s(x,y)d(x,y) = 1 - s(x,y) or d(x,y)=2(1−s(x,y))d(x,y) = \sqrt{2(1-s(x,y))} for cosine similarity specifically (the latter is a true metric when vectors are unit-normalized). The key requirement when converting is checking whether the resulting function still satisfies the triangle inequality if your downstream algorithm depends on that property, such as spatial indexing structures used for fast nearest-neighbor search.

Why does standardizing features before computing Euclidean distance sometimes hurt rather than help?

Standardization assumes each feature's variance is equally informative for defining similarity, which is not always true. If one feature has low variance because it is genuinely uninformative noise, standardizing inflates its influence to match informative high-variance features, potentially degrading cluster quality. Mahalanobis distance offers a partial remedy by accounting for the full covariance structure rather than treating features independently, but it introduces its own risks around estimating covariance reliably from limited data. The right approach depends on domain knowledge about which features actually carry signal.

Before this

Where this leads