2.6. Covariance estimation
Many statistical problems require the estimation of a
population’s covariance matrix, which can be seen as an estimation of
data set scatter plot shape. Most of the time, such an estimation has
to be done on a sample whose properties (size, structure, homogeneity)
have a large influence on the estimation’s quality. The
sklearn.covariance package provides tools for accurately estimating
a population’s covariance matrix under various settings.
We assume that the observations are independent and identically distributed (i.i.d.).
2.6.1. Empirical covariance
The covariance matrix of a data set is known to be well approximated by the classical maximum likelihood estimator (or “empirical covariance”), provided the number of observations is large enough compared to the number of features (the variables describing the observations). More precisely, the Maximum Likelihood Estimator of a sample is an asymptotically unbiased estimator of the corresponding population’s covariance matrix.
The empirical covariance matrix of a sample can be computed using the
function of the package, or by fitting an
object to the data sample with the
method. Be careful that results depend
on whether the data are centered, so one may want to use the
parameter accurately. More precisely, if , then
all features in the train and test sets should have a mean of zero. If not, both should
be centered by the user, or should be used.

