Normal data in 2-D is modelled as a Gaussian with mean and covariance . What is the squared Mahalanobis distance of and of , which is anomalous at the 1% level, and would a model that treats the two features as independent Gaussians notice the difference?
Unsupervised learning, Anomaly detection
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can invert a covariance matrix, compute Mahalanobis distances, and see why modelling the correlation matters.
Key idea
The squared Mahalanobis distance measures distance in units of the data's own spread, taking correlation into account. The Gaussian density is proportional to , so a large means low density. For normal 2-D data, follows a chi-squared distribution with 2 degrees of freedom (), so flag if exceeds its 99% point, .
Steps
- Invert the covariance. For a matrix, , so .
- For : .
- For : .
- Compare with 9.21: is normal and is anomalous. Its density is lower than that of by a factor of .
- Independent-features model: each coordinate is treated as on its own, so both points get and look equally normal. Only the full covariance sees that breaks the strong positive correlation: when goes up, normally goes up too.
- Add the practical side: estimate and from clean training data, and choose the threshold on a labelled validation set (for example, to maximise F1), not on the test set.
Common mistakes
- Using Euclidean distance. Both points are from the mean, so it cannot tell them apart.
- Getting the sign of the off-diagonal entries wrong when inverting .
- Comparing instead of with the cut-off.
How long your answer should be
Half a page of arithmetic; about 4 minutes.
Read this
Previous in Unsupervised learning: A data matrix has one feature per column. Its covariance matrix decomposes as with and . (a) What is the shape of ? (b) What steps compute from , and what is explicitly? (c) To what dimension would you reduce the data with PCA, onto which direction, and why?
Next in Unsupervised learning: A 2-D dataset has two clusters: 50 points evenly spaced on a circle of radius 1 and 200 points evenly spaced on a circle of radius 5, both centred at the origin. (a) Can fuzzy c-means with separate the two rings? (b) Can DBSCAN, and which values of and MinPts work, which fail, and why?