Mahalanobis Distance Outliers

medium
Unit 18 · Online Learning0/2 to milestone

Points can look normal on each feature yet be unusual jointly. The Mahalanobis distance accounts for correlations:

d(x)=(x−μ)⊤Σ−1(x−μ)d(x) = \sqrt{(x - \mu)^\top \Sigma^{-1}(x - \mu)}

Implement mahalanobis(X, mu, cov) returning distances for each row, and flag_outliers(X, threshold) that estimates mu and cov (ddof=1) from X and flags rows whose distance exceeds threshold.

#outliers#statistics#multivariate2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Mahalanobis Distance Outliers · TechGradify