Skip to content

DOC Ensures that GraphicalLasso passes numpydoc validation #20527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"GaussianRandomProjection",
"GradientBoostingClassifier",
"GradientBoostingRegressor",
"GraphicalLasso",
"GraphicalLassoCV",
"GridSearchCV",
"HalvingGridSearchCV",
Expand Down
8 changes: 3 additions & 5 deletions sklearn/covariance/_empirical_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
----------
Expand Down
15 changes: 9 additions & 6 deletions sklearn/covariance/_graph_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ class GraphicalLasso(EmpiricalCovariance):

.. versionadded:: 0.24

See Also
--------
graphical_lasso : L1-penalized covariance estimator.
GraphicalLassoCV : Sparse inverse covariance with
cross-validated choice of the l1 penalty.

Examples
--------
>>> import numpy as np
Expand All @@ -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__(
Expand All @@ -418,19 +420,20 @@ 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.

Returns
-------
self : object
Returns the instance itself.
"""
# Covariance does not make sense for a single feature
X = self._validate_data(
Expand Down