Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ward linkage ValueError with l2 affinity (Agglomerative Clustering) #18531

Copy link
Copy link
Open
@mas1

Description

@mas1
Issue body actions

Describe the bug

When using sklearn.cluster.AgglomerativeClustering, a ValueError "Ward can only work with euclidean distances." is thrown when using ward linkage and l2 affinity. l2 should also work since it is the same thing as euclidean. This is a quite simple problem and I have a fix ready to submit a pull request.

Steps/Code to Reproduce

To simply reproduce with no imports. (self.linkage and self.affinity are altered here to make it easily reproducible)

self_linkage = 'ward'
self_affinity = 'l2'     
        
if self_linkage == "ward" and self_affinity != "euclidean":
  raise ValueError("%s was provided as affinity. Ward can only "
  "work with euclidean distances." %
  (self_affinity, ))

Expected Results

When using l2 affinity, no ValueError should be thrown.

Actual Results

ValueError("%s was provided as affinity. Ward can only "
"work with euclidean distances." %
(self_affinity, ))

Versions

System:
python: 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
executable: /usr/bin/python3
machine: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic

Python dependencies:
pip: 19.3.1
setuptools: 50.3.0
sklearn: 0.22.2.post1
numpy: 1.18.5
scipy: 1.4.1
Cython: 0.29.21
pandas: 1.1.2
matplotlib: 3.2.2
joblib: 0.16.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.