sklearn.covariance.oas

sklearn.covariance.oas(X, *, assume_centered=False)[source]

Estimate covariance with the Oracle Approximating Shrinkage algorithm.

Parameters:
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.

Returns:
shrunk_covarray-like of shape (n_features, n_features)

Shrunk covariance.

shrinkagefloat

Coefficient in the convex combination used for the computation of the shrunk estimate.

Notes

The regularised (shrunk) covariance is:

(1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

where mu = trace(cov) / n_features

The formula we used to implement the OAS is slightly modified compared to the one given in the article. See OAS for more details.