I want to test the various covariance estimators implemented in scikit-learn (for outlier detection). Each of these methods implement a mahalanobis(observations) function. The doc says:
The provided observations are assumed to be centered.
One may want to center them using a location estimate first.
But in the source code of, for example, EmpiricalCovariance, we have:
def mahalanobis(self, observations):
(...)
centered_obs = observations - self.location_
mahalanobis_dist = np.sum(
np.dot(centered_obs, precision) * centered_obs, 1)
As far as I understand, it seems to me that the observations are centered during the computation, so I don't understand why the doc says we need to center the observations? Have I miss something?
Moreover, it seems to me that in this case, the location corresponds to a simple mean. I think that, for MinCovDet estimator, the location really is the reweighted estimator as reweight_covariance() is called at the end of the fit() method, am I right?
I really like the boxplots presented as examples in the doc, but I don't understand why we have the cube root of the distance?
Edit:thanks for the answer for EmpiricalCovariance, but what happen for the other covariance estimators (MincovDet, ShrunkCovariance)? Is it the same? And then, in all these cases, is it the squared Mahalanobis distance that is returned?