LedoitWolf Estimator
Ledoit-Wolf is a particular form of shrinkage, where the shrinkage coefficient is computed using O. Ledoit and M. Wolf's formula as described in 'A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices', Ledoit and Wolf, Journal of Multivariate Analysis, Volume 88, Issue 2, February 2004, pages 365-411.
Read more in the :ref:`User Guide <shrunk_covariance>`.
Parameters ---------- store_precision : bool, default=True Specify if the estimated precision is stored.
assume_centered : bool, default=False If True, data will not be centered before computation. Useful when working with data whose mean is almost, but not exactly zero. If False (default), data will be centered before computation.
block_size : int, default=1000 Size of the blocks into which the covariance matrix will be split during its Ledoit-Wolf estimation. This is purely a memory optimization and does not affect results.
Attributes ---------- location_ : array-like, shape (n_features,) Estimated location, i.e. the estimated mean.
covariance_ : array-like, shape (n_features, n_features) Estimated covariance matrix
precision_ : array-like, shape (n_features, n_features) Estimated pseudo inverse matrix. (stored only if store_precision is True)
shrinkage_ : float, 0 <= shrinkage <= 1 Coefficient in the convex combination used for the computation of the shrunk estimate.
Examples -------- >>> import numpy as np >>> from sklearn.covariance import LedoitWolf >>> real_cov = np.array([.4, .2],
... [.2, .8]
) >>> np.random.seed(0) >>> X = np.random.multivariate_normal(mean=0, 0
, ... cov=real_cov, ... size=50) >>> cov = LedoitWolf().fit(X) >>> cov.covariance_ array([0.4406..., 0.1616...],
[0.1616..., 0.8022...]
) >>> cov.location_ array( 0.0595... , -0.0075...
)
Notes ----- The regularised covariance is:
(1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)
where mu = trace(cov) / n_features and shrinkage is given by the Ledoit and Wolf formula (see References)
References ---------- 'A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices', Ledoit and Wolf, Journal of Multivariate Analysis, Volume 88, Issue 2, February 2004, pages 365-411.