Oracle Approximating Shrinkage Estimator
Read more in the :ref:`User Guide <shrunk_covariance>`.
OAS is a particular form of shrinkage described in 'Shrinkage Algorithms for MMSE Covariance Estimation' Chen et al., IEEE Trans. on Sign. Proc., Volume 58, Issue 10, October 2010.
The formula used here does not correspond to the one given in the article. In the original article, formula (23) states that 2/p is multiplied by Trace(cov*cov) in both the numerator and denominator, but this operation is omitted because for a large p, the value of 2/p is so small that it doesn't affect the value of the estimator.
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.
Attributes ---------- covariance_ : ndarray of shape (n_features, n_features) Estimated covariance matrix.
location_ : ndarray of shape (n_features,) Estimated location, i.e. the estimated mean.
precision_ : ndarray of shape (n_features, n_features) Estimated pseudo inverse matrix. (stored only if store_precision is True)
shrinkage_ : float coefficient in the convex combination used for the computation of the shrunk estimate. Range is 0, 1
.
Examples -------- >>> import numpy as np >>> from sklearn.covariance import OAS >>> from sklearn.datasets import make_gaussian_quantiles >>> real_cov = np.array([.8, .3],
... [.3, .4]
) >>> rng = np.random.RandomState(0) >>> X = rng.multivariate_normal(mean=0, 0
, ... cov=real_cov, ... size=500) >>> oas = OAS().fit(X) >>> oas.covariance_ array([0.7533..., 0.2763...],
[0.2763..., 0.3964...]
) >>> oas.precision_ array([ 1.7833..., -1.2431... ],
[-1.2431..., 3.3889...]
) >>> oas.shrinkage_ 0.0195...
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 OAS formula (see References)
References ---------- 'Shrinkage Algorithms for MMSE Covariance Estimation' Chen et al., IEEE Trans. on Sign. Proc., Volume 58, Issue 10, October 2010.