8000 DOC add link to cluster_plot_ward_structured_vs_unstructured in _aggl… by mahmadza · Pull Request #30861 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC add link to cluster_plot_ward_structured_vs_unstructured in _aggl… #30861

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mahmadza
Copy link
Contributor

Reference Issues/PRs

Towards #30621

What does this implement/fix? Explain your changes.

Added a link to structured vs unstructured ward hierarchical clustering example in AgglomerativeClustering class.

Copy link
github-actions bot commented Feb 19, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: e1d4b36. Link to the linter CI: here

Copy link
Contributor
@StefanieSenger StefanieSenger left a comment

Choose a reason for hiding this comment

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

That looks good, thank you @mahmadza.

Basically, the examples are so similar, that we might want to join them later. But for now, I would merge this PR, since it is better to hint users to both usage examples than to only one, even if they don't differ so much.

@adrinjalali, what do you think about this?

@adrinjalali
Copy link
Member

They're almost the same example. I'd merge them in this PR. Would you be up for it @mahmadza ? You'd need to remove plot_agglomerative_clustering.py, and merge the relevant parts of its content with the other example. Then you'd add a redirect from the old example to the new one here:

redirects = {

And remove all mentions of the old example from the codebase.

@mahmadza
Copy link
Contributor Author

Sure I can do that. To summarize what I need to do:

  • merge relevant parts of examples.cluster.plot_agglomerative_clustering.py into examples.cluster.plot_ward_structured_vs_unstructured.py
  • delete examples.cluster.plot_agglomerative_clustering.py
  • add redirects from examples.cluster.plot_agglomerative_clustering.py to the new examples.cluster.plot_ward_structured_vs_unstructured.py in
    redirects = {
    .
  • delete all mentions of :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_clustering.py` in the code base.

Let me know if my understanding is correct.

@mahmadza
Copy link
Contributor Author

@StefanieSenger @adrinjalali All requested changes have been completed.

Comment on lines +29 to +31
from sklearn.cluster import AgglomerativeClustering
from sklearn.datasets import make_swiss_roll
from sklearn.neighbors import kneighbors_graph
Copy link
Member

Choose a reason for hiding this comment

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

in our (modern) examples, we tend to have the imports in the same cell that they're first used, instead of having them all on top of the file.

Comment on lines +43 to +44
# Compute clustering without connectivity constraints
# --------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Compute clustering without connectivity constraints
# --------------------------------------------------
# Compute clustering without connectivity constraints
# ---------------------------------------------------

They need to be of the same length

Comment on lines -752 to +757
.. image:: ../auto_examples/cluster/images/sphx_glr_plot_agglomerative_clustering_001.png
:target: ../auto_examples/cluster/plot_agglomerative_clustering.html
.. image:: ../auto_examples/cluster/images/sphx_glr_plot_ward_structured_vs_unstructured_001.png
:target: ../auto_examples/cluster/plot_ward_structured_vs_unstructured.html
:scale: 38

.. image:: ../auto_examples/cluster/images/sphx_glr_plot_agglomerative_clustering_002.png
:target: ../auto_examples/cluster/plot_agglomerative_clustering.html
:scale: 38

.. image:: ../auto_examples/cluster/images/sphx_glr_plot_agglomerative_clustering_003.png
:target: ../auto_examples/cluster/plot_agglomerative_clustering.html
:scale: 38

.. image:: ../auto_examples/cluster/images/sphx_glr_plot_agglomerative_clustering_004.png
:target: ../auto_examples/cluster/plot_agglomerative_clustering.html
.. image:: ../auto_examples/cluster/images/sphx_glr_plot_ward_structured_vs_unstructured_002.png
:target: ../auto_examples/cluster/plot_ward_structured_vs_unstructured.html
Copy link
Member

Choose a reason for hiding this comment

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

This part of the diff is sort of a regression in the docs.

Before the change, this is how it looks:

image

and after, it looks like this:

image

The "before" is much clearer and shows the intent of the warning very nicely. We should make sure the new example covers the topic and that the linked pictures also show the intent of the warning.

@marenwestermann
Copy link
Member

Hi @mahmadza, would you like to continue working on this pull request?

@mahmadza
Copy link
Contributor Author
mahmadza commented Jun 2, 2025

Hi @mahmadza, would you like to continue working on this pull request?

@adrinjalali @marenwestermann sorry for the delay.
@marenwestermann , you can take over if interested.

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.

4 participants
0