class sklearn.covariance.EmpiricalCovariance(store_precision=True, assume_centered=False) [source]
Maximum likelihood covariance estimator
Read more in the User Guide.
| Parameters: |
|
|---|---|
| Attributes: |
|
>>> import numpy as np
>>> from sklearn.covariance import EmpiricalCovariance
>>> 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 = EmpiricalCovariance().fit(X)
>>> cov.covariance_
array([[0.7569..., 0.2818...],
[0.2818..., 0.3928...]])
>>> 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 Maximum Likelihood Estimator 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 log-likelihood 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) [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 Maximum Likelihood Estimator 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 log-likelihood 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.EmpiricalCovariance
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html