8000 DOC Fix notebook style of plot_coin_ward_segmentation by lucyleeow · Pull Request #23164 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Fix notebook style of plot_coin_ward_segmentation #23164

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 5 commits into from
Apr 21, 2022

Conversation

lucyleeow
Copy link
Member

Reference Issues/PRs

#22406

What does this implement/fix? Explain your changes.

Fixes the notebook style of the example

Any other comments?

@lucyleeow lucyleeow changed the title fix notebook style Fix notebook style of plot_coin_ward_segmentation Apr 20, 2022
@lucyleeow lucyleeow changed the title Fix notebook style of plot_coin_ward_segmentation DOC Fix notebook style of plot_coin_ward_segmentation Apr 20, 2022
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.

A couple of comments to improve a bit the example.
Otherwise LGTM.
Thanks @lucyleeow

# Generate data
# -------------

orig_coins = coins()

# Resize it to 20% of the original size to speed up the processing
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
# Resize it to 20% of the original size to speed up the processing
# %%
# Resize it to 20% of the original size to speed up the processing

@@ -27,8 +27,10 @@
from sklearn.cluster import AgglomerativeClustering
Copy link
Member

Choose a reason for hiding this comment

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

Since we are modifying the example, you can move the import to the cell where it is used the first time.

@@ -41,12 +43,18 @@

Copy link
Member

Choose a reason for hiding this comment

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

A FutureWarning is raised by rescale because of multichannel=False. Indeed, it was already the default so we can simply remove this keyword.

# Plot the results on an image
# ----------------------------

plt.figure(figsize=(5, 5))
plt.imshow(rescaled_coins, cmap=plt.cm.gray)
for l in range(n_clusters):
Copy link
Member

Choose a reason for hiding this comment

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

instead of plot.xticks and plt.yticks, let use plt.axis("off") which is more meaningful.

@@ -59,8 +67,10 @@
print("Number of pixels: ", label.size)
Copy link
Member

Choose a reason for hiding this comment

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

Let's use some f-string in the different print statement and use {time.time() - st:.3f} s instead of showing too many digits

# Plot the results on an image
# ----------------------------

Copy link
Member

Choose a reason for hiding this comment

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

After showing the image, it could be nice to add a small sentence to describe the results. In short, we are able to segment the different coins but we need to provide n_clusters larger than the actual number of coins because the segmentation is finding a large cluster in the background.

@lesteve lesteve added the Quick Review For PRs that are quick to review label Apr 20, 2022
@lesteve lesteve mentioned this pull request Apr 20, 2022
47 tasks
@lucyleeow
Copy link
Member Author

Thanks for review @glemaitre ! Changes made

@lucyleeow
Copy link
Member Author

The CI failures seem unrelated to this PR

@glemaitre
Copy link
Member

The CI failures seem unrelated to this PR

Yes, there is a PR to solve this problem.

1 similar comment
@glemaitre
Copy link
Member

The CI failures seem unrelated to this PR

Yes, there is a PR to solve this problem.

@glemaitre
Copy link
Member

I directly made the changes since the example looks fine otherwise.
LGTM. I will merge once the CIs are green.

@@ -9,44 +9,55 @@

"""

# %%
Copy link
Member

Choose a reason for hiding this comment

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

This marker makes the rendering weird with some of the font being in bold.
You can either revert or make the rendering maybe with some RST items, as you prefer.

@glemaitre glemaitre merged commit 1e96578 into scikit-learn:main Apr 21, 2022
@glemaitre
Copy link
Member

@lucyleeow Thanks merging.

@lucyleeow lucyleeow deleted the plot_coin branch April 22, 2022 00:05
jjerphan pushed a commit to jjerphan/scikit-learn that referenced this pull request Apr 29, 2022
…3164)

Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Quick Review For PRs that are quick to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0