8000 [MRG+1] Deprecate pooling_func unused parameter in AgglomerativeClust… · scikit-learn/scikit-learn@b4561f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b4561f0

Browse files
thechargedneutronlesteve
authored andcommitted
[MRG+1] Deprecate pooling_func unused parameter in AgglomerativeClustering (#9875)
1 parent e028944 commit b4561f0

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

doc/whats_new/v0.20.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ Metrics
142142
for :func:`metrics.roc_auc_score`. Moreover using ``reorder=True`` can hide bugs
143143
due to floating point error in the input.
144144
:issue:`9851` by :user:`Hanmin Qin <qinhanmin2014>`.
145+
146+
Cluster
147+
148+
- Deprecate ``pooling_func`` unused parameter in
149+
:class:`cluster.AgglomerativeClustering`. :issue:`9875` by :user:`Kumar Ashutosh
150+
<thechargedneutron>`.

sklearn/cluster/hierarchical.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,12 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
641641
- complete or maximum linkage uses the maximum distances between
642642
all observations of the two sets.
643643
644-
pooling_func : callable, default=np.mean
645-
This combines the values of agglomerated features into a single
646-
value, and should accept an array of shape [M, N] and the keyword
647-
argument ``axis=1``, and reduce it to an array of size [M].
644+
pooling_func : callable, default='deprecated'
645+
Ignored.
646+
647+
.. deprecated:: 0.20
648+
``pooling_func`` has been deprecated in 0.20 and will be removed
649+
in 0.22.
648650
649651
Attributes
650652
----------
@@ -670,7 +672,7 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
670672
def __init__(self, n_clusters=2, affinity="euclidean",
671673
memory=None,
672674
connectivity=None, compute_full_tree='auto',
673-
linkage='ward', pooling_func=np.mean):
675+
linkage='ward', pooling_func='deprecated'):
674676
self.n_clusters = n_clusters
675677
self.memory = memory
676678
self.connectivity = connectivity
@@ -694,6 +696,10 @@ def fit(self, X, y=None):
694696
-------
695697
self
696698
"""
699+
if self.pooling_func != 'deprecated':
700+
warnings.warn('Agglomerative "pooling_func" parameter is not used.'
701+
' It has been deprecated in version 0.20 and will be'
702+
'removed in 0.22', DeprecationWarning)
697703
X = check_array(X, ensure_min_samples=2, estimator=self)
698704
memory = check_memory(self.memory)
699705

@@ -829,6 +835,16 @@ class FeatureAgglomeration(AgglomerativeClustering, AgglomerationTransform):
829835
are merged to form node `n_features + i`
830836
"""
831837

838+
def __init__(self, n_clusters=2, affinity="euclidean",
839+
memory=None,
840+
connectivity=None, compute_full_tree='auto',
841+
linkage='ward', pooling_func=np.mean):
842+
super(FeatureAgglomeration, self).__init__(
843+
n_clusters=n_clusters, memory=memory, connectivity=connectivity,
844+
compute_full_tree=compute_full_tree, linkage=linkage,
845+
affinity=affinity)
846+
self.pooling_func = pooling_func
847+
832848
def fit(self, X, y=None, **params):
833849
"""Fit the hierarchical clustering on the data
834850

0 commit comments

Comments
 (0)
0