sklearn.covariance.ledoit_wolf¶
- sklearn.covariance.ledoit_wolf(X, assume_centered=False, block_size=1000)¶
Estimates the shrunk Ledoit-Wolf covariance matrix.
Parameters: X : array-like, shape (n_samples, n_features)
Data from which to compute the covariance estimate
assume_centered : Boolean
If True, data are not centered before computation. Useful to work with data whose mean is significantly equal to zero but is not exactly zero. If False, data are centered before computation.
block_size : int,
Size of the blocks into which the covariance matrix will be split. If n_features > block_size, an error will be raised since the shrunk covariance matrix will be considered as too large regarding the available memory.
Returns: shrunk_cov : array-like, shape (n_features, n_features)
Shrunk covariance.
shrinkage : float
Coefficient in the convex combination used for the computation of the shrunk estimate.
Notes
The regularized (shrunk) covariance is:
- (1 - shrinkage)*cov
- shrinkage * mu * np.identity(n_features)
where mu = trace(cov) / n_features