Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Micky774
Copy link
Contributor

Reference Issues/PRs

Resolves #13945

What does this implement/fix? Explain your changes.

Deprecates affinity in favor of metric in AgglomerativeClustering

Any other comments?

Probably worth propagating the deprecation to linkage_tree in a follow-up PR.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit undecided if this is worth the deprecation cycle. I think it comes down to "do we want to switch from affinity everywhere". If yes, then I think it's worth going through deprecation.

I think the questionable case is AffinityPropagation. Should affinity in AffinityPropagation by renamed to metric?

@Micky774
Copy link
Contributor Author

Micky774 commented Jun 2, 2022

I'm a bit undecided if this is worth the deprecation cycle. I think it comes down to "do we want to switch from affinity everywhere". If yes, then I think it's worth going through deprecation.

It's definitely something that should happen in series, if at all, otherwise having only some mentions move to metric while some stay affinity would be very painful.

I think the questionable case is AffinityPropagation. Should affinity in AffinityPropagation by renamed to metric?

I think that should stay affinity. The docstring specifies that affinity="precomputed" does indeed expect a similarity matrix, and that affinity="euclidean" uses the negative squared Euclidean distances, which is a similarity.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with the deprecation.

@glemaitre glemaitre self-requested a review June 30, 2022 07:45
@glemaitre
Copy link
Member

I just sync with main since we introduced the parameter validation since this PR was open.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment otherwise LGTM!

@glemaitre
Copy link
Member

Could you modify the following example as well to avoid raising the warning:

  • examples/cluster/plot_agglomerative_clustering_metrics.py
  • examples/cluster/plot_cluster_comparison.py (I see that we might have the same inconsistency in SpectralClustering).

@Micky774
Copy link
Contributor Author

Micky774 commented Jul 6, 2022

Could you modify the following example as well to avoid raising the warning:

  • examples/cluster/plot_agglomerative_clustering_metrics.py
  • examples/cluster/plot_cluster_comparison.py (I see that we might have the same inconsistency in SpectralClustering).

Fixed, good catch.

I think that SpectralClustering is fine since it genuinely builds an affinity/similarity matrix. In particular affinity="precomputed" demands an affinity/similarity matrix.

@glemaitre glemaitre merged commit a5d50cf into scikit-learn:main Jul 6, 2022
@glemaitre
Copy link
Member

LGTM THanks @Micky774

@Micky774 Micky774 deleted the deprecate_affinity branch July 6, 2022 15:03
Harsh14901 pushed a commit to Harsh14901/scikit-learn that referenced this pull request Jul 6, 2022
…3470)

Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
ogrisel pushed a commit to ogrisel/scikit-learn that referenced this pull request Jul 11, 2022
…3470)

Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
@EwoutH
Copy link

EwoutH commented Dec 8, 2022

Hi! Can we change just change the keyword from affinity to metric in scikit-learn 1.2 without a change in behaviour? Any exceptions or caveats?

@Micky774
Copy link
Contributor Author

Micky774 commented Dec 8, 2022

Hi! Can we change just change the keyword from affinity to metric in scikit-learn 1.2 without a change in behaviour? Any exceptions or caveats?

Yes, you should be able to replace affinity-->metric with no change in behavior!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AgglomerativeClustering] confusing parameter 'affinity'

4 participants