- sklearn.covariance.oas(X, *, assume_centered=False)¶
Estimate covariance with the Oracle Approximating Shrinkage as proposed in .
Read more in the User Guide.
- Xarray-like of shape (n_samples, n_features)
Data from which to compute the covariance estimate.
- assume_centeredbool, default=False
If True, data will not be centered before computation. Useful to work with data whose mean is significantly equal to zero but is not exactly zero. If False, data will be centered before computation.
- shrunk_covarray-like of shape (n_features, n_features)
Coefficient in the convex combination used for the computation of the shrunk estimate.
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 ).
The shrinkage formulation implemented here differs from Eq. 23 in . In the original article, formula (23) states that 2/p (p being the number of features) 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.