From fa6b3b727346147214a4897389f68320092fad5e Mon Sep 17 00:00:00 2001 From: genvalen Date: Tue, 13 Jul 2021 20:59:26 -0400 Subject: [PATCH 1/4] Remove GraphicalLasso from DOCSTRING_IGNORE_LIST. --- maint_tools/test_docstrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 8734cef219bb2..178285bd9f714 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -42,7 +42,6 @@ "GaussianRandomProjection", "GradientBoostingClassifier", "GradientBoostingRegressor", - "GraphicalLasso", "GraphicalLassoCV", "GridSearchCV", "HalvingGridSearchCV", From d5f4b43aae0bc4e89b84bbfb58e1c074ad07c2d9 Mon Sep 17 00:00:00 2001 From: genvalen Date: Tue, 13 Jul 2021 22:39:26 -0400 Subject: [PATCH 2/4] Ensure GraphicalLasso passes numpydoc validation in_graph_lasso.py --- sklearn/covariance/_graph_lasso.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sklearn/covariance/_graph_lasso.py b/sklearn/covariance/_graph_lasso.py index b8b022ee7998b..af2fbfb01a136 100644 --- a/sklearn/covariance/_graph_lasso.py +++ b/sklearn/covariance/_graph_lasso.py @@ -372,6 +372,12 @@ class GraphicalLasso(EmpiricalCovariance): .. versionadded:: 0.24 + See Also + -------- + graphical_lasso : L1-penalized covariance estimator. + GraphicalLassoCV : Sparse inverse covariance w/ + cross-validated choice of the l1 penalty. + Examples -------- >>> import numpy as np @@ -392,10 +398,6 @@ class GraphicalLasso(EmpiricalCovariance): [0.019, 0.034, 0.093, 0.69 ]]) >>> np.around(cov.location_, decimals=3) array([0.073, 0.04 , 0.038, 0.143]) - - See Also - -------- - graphical_lasso, GraphicalLassoCV """ def __init__( @@ -418,12 +420,12 @@ def __init__( self.verbose = verbose def fit(self, X, y=None): - """Fits the GraphicalLasso model to X. + """Fit the GraphicalLasso model to X. Parameters ---------- X : array-like of shape (n_samples, n_features) - Data from which to compute the covariance estimate + Data from which to compute the covariance estimate. y : Ignored Not used, present for API consistency by convention. @@ -431,6 +433,7 @@ def fit(self, X, y=None): Returns ------- self : object + Returns the instance itself. """ # Covariance does not make sense for a single feature X = self._validate_data( From 40d3ea049f88454c18a168a17394413e93bd51a4 Mon Sep 17 00:00:00 2001 From: genvalen Date: Tue, 13 Jul 2021 23:14:13 -0400 Subject: [PATCH 3/4] Ensure GraphicalLasso passes numpydoc validation in _empirical_covariance.py --- sklearn/covariance/_empirical_covariance.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sklearn/covariance/_empirical_covariance.py b/sklearn/covariance/_empirical_covariance.py index de2c4c047c03e..4ffab8af5ceea 100644 --- a/sklearn/covariance/_empirical_covariance.py +++ b/sklearn/covariance/_empirical_covariance.py @@ -218,8 +218,7 @@ def fit(self, X, y=None): return self def score(self, X_test, y=None): - """Computes the log-likelihood of a Gaussian data set with - `self.covariance_` as an estimator of its covariance matrix. + """Compute the log-likelihood of a Gaussian data set with `self.covariance_`. Parameters ---------- @@ -247,8 +246,7 @@ def score(self, X_test, y=None): return res def error_norm(self, comp_cov, norm="frobenius", scaling=True, squared=True): - """Computes the Mean Squared Error between two covariance estimators. - (In the sense of the Frobenius norm). + """Compute the Mean Squared Error between two covariance estimators. Parameters ---------- @@ -299,7 +297,7 @@ def error_norm(self, comp_cov, norm="frobenius", scaling=True, squared=True): return result def mahalanobis(self, X): - """Computes the squared Mahalanobis distances of given observations. + """Compute the squared Mahalanobis distances of given observations. Parameters ---------- From a49f7769ff669fcac657982fa77d9a5c6899fac9 Mon Sep 17 00:00:00 2001 From: genvalen Date: Thu, 15 Jul 2021 10:57:38 -0400 Subject: [PATCH 4/4] Update sklearn/covariance/_graph_lasso.py Co-authored-by: Guillaume Lemaitre --- sklearn/covariance/_graph_lasso.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/covariance/_graph_lasso.py b/sklearn/covariance/_graph_lasso.py index af2fbfb01a136..642a1dc2a9214 100644 --- a/sklearn/covariance/_graph_lasso.py +++ b/sklearn/covariance/_graph_lasso.py @@ -375,7 +375,7 @@ class GraphicalLasso(EmpiricalCovariance): See Also -------- graphical_lasso : L1-penalized covariance estimator. - GraphicalLassoCV : Sparse inverse covariance w/ + GraphicalLassoCV : Sparse inverse covariance with cross-validated choice of the l1 penalty. Examples