Skip to content

[WIP] DOC Ensures that FeatureAgglomeration passes numpydoc validation #20851

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

1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"DictionaryLearning",
"ElasticNetCV",
"FactorAnalysis",
"FeatureAgglomeration",
"FeatureHasher",
"FeatureUnion",
"FunctionTransformer",
Expand Down
19 changes: 14 additions & 5 deletions sklearn/cluster/_agglomerative.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,7 @@ def fit(self, X, y=None):
return self

def fit_predict(self, X, y=None):
"""Fit the hierarchical clustering from features or distance matrix,
and return cluster labels.
"""Fit the hierarchical clustering from features or distance matrix.

Parameters
----------
Expand Down Expand Up @@ -1123,6 +1122,11 @@ class FeatureAgglomeration(AgglomerativeClustering, AgglomerationTransform):
Only computed if `distance_threshold` is used or `compute_distances`
is set to `True`.

See Also
--------
AgglomerativeClustering : It performs a hierarchical clustering using
a bottom up approach.

Examples
--------
>>> import numpy as np
Expand Down Expand Up @@ -1164,18 +1168,23 @@ def __init__(
self.pooling_func = pooling_func

def fit(self, X, y=None, **params):
"""Fit the hierarchical clustering on the data
"""Fit the hierarchical clustering on the data.

Parameters
----------
X : array-like of shape (n_samples, n_features)
The data
The data.

y : Ignored
Ignored parameter.

**params : dict
Additional fit parameters.

Returns
-------
self
self : object
FeatureAgglomeration class instance.
"""
X = self._validate_data(
X,
Expand Down
10 changes: 5 additions & 5 deletions sklearn/cluster/_feature_agglomeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AgglomerationTransform(TransformerMixin):

def transform(self, X):
"""
Transform a new matrix using the built clustering
Transform a new matrix using the built clustering.

Parameters
----------
Expand Down Expand Up @@ -54,15 +54,15 @@ def transform(self, X):
return nX

def inverse_transform(self, Xred):
"""
Inverse the transformation.
"""Inverse the transformation.

Return a vector of size nb_features with the values of Xred assigned
to each group of features
to each group of features.

Parameters
----------
Xred : array-like of shape (n_samples, n_clusters) or (n_clusters,)
The values to be assigned to each cluster of samples
The values to be assigned to each cluster of samples.

Returns
-------
Expand Down