class sklearn.covariance.ShrunkCovariance(store_precision=True, assume_centered=False, shrinkage=0.1)
[source]
Covariance estimator with shrinkage
Read more in the User Guide.
Parameters: 


Attributes: 

The regularized covariance is given by:
(1  shrinkage) * cov + shrinkage * mu * np.identity(n_features)
where mu = trace(cov) / n_features
>>> import numpy as np >>> from sklearn.covariance import ShrunkCovariance >>> from sklearn.datasets import make_gaussian_quantiles >>> real_cov = np.array([[.8, .3], ... [.3, .4]]) >>> np.random.seed(0) >>> X = np.random.multivariate_normal(mean=[0, 0], ... cov=real_cov, ... size=500) >>> cov = ShrunkCovariance().fit(X) >>> cov.covariance_ array([[0.7387..., 0.2536...], [0.2536..., 0.4110...]]) >>> cov.location_ array([0.0622..., 0.0193...])
error_norm (comp_cov[, norm, scaling, squared])  Computes the Mean Squared Error between two covariance estimators. 
fit (X[, y])  Fits the shrunk covariance model according to the given training data and parameters. 
get_params ([deep])  Get parameters for this estimator. 
get_precision ()  Getter for the precision matrix. 
mahalanobis (X)  Computes the squared Mahalanobis distances of given observations. 
score (X_test[, y])  Computes the loglikelihood of a Gaussian data set with self.covariance_ as an estimator of its covariance matrix. 
set_params (**params)  Set the parameters of this estimator. 
__init__(store_precision=True, assume_centered=False, shrinkage=0.1)
[source]
error_norm(comp_cov, norm=’frobenius’, scaling=True, squared=True)
[source]
Computes the Mean Squared Error between two covariance estimators. (In the sense of the Frobenius norm).
Parameters: 


Returns: 

fit(X, y=None)
[source]
Fits the shrunk covariance model according to the given training data and parameters.
Parameters: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

get_precision()
[source]
Getter for the precision matrix.
Returns: 


mahalanobis(X)
[source]
Computes the squared Mahalanobis distances of given observations.
Parameters: 


Returns: 

score(X_test, y=None)
[source]
Computes the loglikelihood of a Gaussian data set with self.covariance_
as an estimator of its covariance matrix.
Parameters: 


Returns: 

set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: 


sklearn.covariance.ShrunkCovariance
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.covariance.ShrunkCovariance.html