10000 [MRG+1] Improves class design for AgglomerativeClustering and FeatureAgglomeration by thechargedneutron · Pull Request #9875 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] Improves class design for AgglomerativeClustering and FeatureAgglomeration #9875

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 23 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1ab0c1d
first commit
thechargedneutron Oct 5, 2017
dd5451e
super statement corrected
thechargedneutron Oct 5, 2017
261f5de
Y changed with y
thechargedneutron Oct 5, 2017
22bbb9a
return statement added to fit function
thechargedneutron Oct 17, 2017
a6de709
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 17, 2017
7c682c2
init of FeatureAgglomeration corrected
thechargedneutron Oct 17, 2017
fe1d7bc
Changes reverted
thechargedneutron Oct 18, 2017
705985a
DeprecationWarning added
thechargedneutron Oct 18, 2017
260d8cf
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 18, 2017
6aff6a5
flake8 failures removed
thechargedneutron Oct 18, 2017
c5ea897
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 18, 2017
57a7713
changes added
thechargedneutron Oct 18, 2017
b6d77c4
warning shifted to fit
thechargedneutron Oct 18, 2017
9595ec0
parameter description changed
thechargedneutron Oct 18, 2017
ca9404b
super statement added
thechargedneutron Oct 19, 2017
f3d87e3
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 19, 2017
83a397a
changes added
thechargedneutron Oct 21, 2017
140e997
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 21, 2017
2eca9ed
indentation corrected
thechargedneutron Oct 21, 2017
132f40c
parameter doc changed
thechargedneutron Oct 23, 2017
9115d39
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
thechargedneutron Oct 23, 2017
d53ac99
Minor tweak
lesteve Oct 24, 2017
f135448
Add whats_new entry
lesteve Oct 24, 2017
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
6 changes: 6 additions & 0 deletions doc/whats_new/v0.20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ Metrics
for :func:`metrics.roc_auc_score`. Moreover using ``reorder=True`` can hide bugs
due to floating point error in the input.
:issue:`9851` by :user:`Hanmin Qin <qinhanmin2014>`.

Cluster

- Deprecate ``pooling_func`` unused parameter in
:class:`cluster.AgglomerativeClustering`. :issue:`9875` by :user:`Kumar Ashutosh
<thechargedneutron>`.
26 changes: 21 additions & 5 deletions sklearn/cluster/hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,12 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
- complete or maximum linkage uses the maximum distances between
all observations of the two sets.

pooling_func : callable, default=np.mean
This combines the values of agglomerated features into a single
value, and should accept an array of shape [M, N] and the keyword
argument ``axis=1``, and reduce it to an array of size [M].
pooling_func : callable, default='deprecated'
Ignored.

.. deprecated:: 0.20
``pooling_func`` has been deprecated in 0.20 and will be removed
in 0.22.

Attributes
----------
Expand All @@ -670,7 +672,7 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
def __init__(self, n_clusters=2, affinity="euclidean",
memory=None,
connectivity=None, compute_full_tree='auto',
linkage='ward', pooling_func=np.mean):
linkage='ward', pooling_func='deprecated'):
self.n_clusters = n_clusters
self.memory = memory
self.connectivity = connectivity
Expand All @@ -694,6 +696,10 @@ def fit(self, X, y=None):
-------
self
"""
if self.pooling_func != 'deprecated':
warnings.warn('Agglomerative "pooling_func" parameter is not used.'
' It has been deprecated in version 0.20 and will be'
'removed in 0.22', DeprecationWarning)
X = check_array(X, ensure_min_samples=2, estimator=self)
memory = check_memory(self.memory)

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

def __init__(self, n_clusters=2, affinity="euclidean",
memory=None,
connectivity=None, compute_full_tree='auto',
linkage='ward', pooling_func=np.mean):
super(FeatureAgglomeration, self).__init__(
n_clusters=n_clusters, memory=memory, connectivity=connectivity,
compute_full_tree=compute_full_tree, linkage=linkage,
affinity=affinity)
self.pooling_func = pooling_func

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

Expand Down
0