Permalink
Browse files

Cosmetic changes in covariance.

  • Loading branch information...
1 parent 762d270 commit f3f7b47e988c7f213c7bf5af90ec7fb1c476e0ab @fabianp fabianp committed Apr 27, 2011
View
@@ -291,6 +291,8 @@ Covariance Estimators
:template: function.rst
covariance.ledoit_wolf
+ covariance.shrunk_covariance
+ covariance.oas
Signal Decomposition
@@ -137,7 +137,7 @@ def fit(self, X, assume_centered=False, **params):
return self
def score(self, X_test, assume_centered=False):
- """Computes the likelihood of a gaussian data set with
+ """Computes the log-likelihood of a gaussian data set with
`self.covariance_` as an estimator of its covariance matrix.
Parameters
@@ -14,6 +14,7 @@
# avoid division truncation
from __future__ import division
+
import numpy as np
from .empirical_covariance_ import empirical_covariance, EmpiricalCovariance
@@ -26,16 +27,17 @@ def shrunk_covariance(emp_cov, shrinkage=0.1):
Params
------
- emp_cov: 2D ndarray, shape (n_features, n_features)
+ emp_cov: array-like, shape (n_features, n_features)
Covariance matrix to be shrunk
+
shrinkage: float, 0 <= shrinkage <= 1
coefficient in the convex combination used for the computation
of the shrunk estimate.
Returns
-------
- shrunk_cov: 2D ndarray
- Shrunk covariance
+ shrunk_cov: array-like
+ shrunk covariance
Notes
-----
@@ -70,10 +72,10 @@ class ShrunkCovariance(EmpiricalCovariance):
Attributes
----------
- `covariance_` : 2D ndarray, shape (n_features, n_features)
+ `covariance_` : array-like, shape (n_features, n_features)
Estimated covariance matrix
- `precision_` : 2D ndarray, shape (n_features, n_features)
+ `precision_` : array-like, shape (n_features, n_features)
Estimated pseudo inverse matrix.
(stored only if store_precision is True)
@@ -133,7 +135,7 @@ def ledoit_wolf(X, assume_centered=False):
Parameters
----------
- X: 2D ndarray, shape (n_samples, n_features)
+ X: array-like, shape (n_samples, n_features)
Data from which to compute the covariance estimate
assume_centered: Boolean
@@ -144,7 +146,7 @@ def ledoit_wolf(X, assume_centered=False):
Returns
-------
- shrunk_cov: 2D ndarray, shape (n_features, n_features)
+ shrunk_cov: array-like, shape (n_features, n_features)
Shrunk covariance
shrinkage: float
@@ -206,10 +208,10 @@ class LedoitWolf(EmpiricalCovariance):
Attributes
----------
- `covariance_` : 2D ndarray, shape (n_features, n_features)
+ `covariance_` : array-like, shape (n_features, n_features)
Estimated covariance matrix
- `precision_` : 2D ndarray, shape (n_features, n_features)
+ `precision_` : array-like, shape (n_features, n_features)
Estimated pseudo inverse matrix.
(stored only if store_precision is True)
@@ -266,22 +268,22 @@ def fit(self, X, assume_centered=False):
# OAS estimator
def oas(X, assume_centered=False):
- """Estimates the covariance matrix with the Oracle Approximating Shrinkage.
+ """Estimate covariance with the Oracle Approximating Shrinkage algorithm.
Parameters
----------
- X: 2D ndarray, shape (n_samples, n_features)
+ X: array-like, shape (n_samples, n_features)
Data from which to compute the covariance estimate
- assume_centered: Boolean
+ assume_centered: boolean
If True, data are not centered before computation.
Usefull to work with data whose mean is significantly equal to
zero but is not exactly zero.
If False, data are centered before computation.
Returns
-------
- shrunk_cov: 2D ndarray, shape (n_features, n_features)
+ shrunk_cov: array-like, shape (n_features, n_features)
Shrunk covariance
shrinkage: float
@@ -340,10 +342,10 @@ class OAS(EmpiricalCovariance):
Attributes
----------
- `covariance_` : 2D ndarray, shape (n_features, n_features)
+ `covariance_` : array-like, shape (n_features, n_features)
Estimated covariance matrix
- `precision_` : 2D ndarray, shape (n_features, n_features)
+ `precision_` : array-like, shape (n_features, n_features)
Estimated pseudo inverse matrix.
(stored only if store_precision is True)
@@ -377,7 +379,7 @@ def fit(self, X, assume_centered=False):
Training data, where n_samples is the number of samples
and n_features is the number of features.
- assume_centered: Boolean
+ assume_centered: boolean
If True, data are not centered before computation.
Usefull to work with data whose mean is significantly equal to
zero but is not exactly zero.
@@ -73,7 +73,7 @@ def test_shrunk_covariance():
assert(cov.precision_ is None)
-def test_lw():
+def test_ledoit_wolf():
"""Tests LedoitWolf module on a simple dataset.
"""

0 comments on commit f3f7b47

Please sign in to comment.