-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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 |
There was a problem hiding this comment.
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 @@ | |||
|
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 | ||
# ---------------------------- | ||
|
There was a problem hiding this comment.
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.
Thanks for review @glemaitre ! Changes made |
The CI failures seem unrelated to this PR |
Yes, there is a PR to solve this problem. |
1 similar comment
Yes, there is a PR to solve this problem. |
I directly made the changes since the example looks fine otherwise. |
@@ -9,44 +9,55 @@ | |||
|
|||
""" | |||
|
|||
# %% |
There was a problem hiding this comment.
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.
@lucyleeow Thanks merging. |
…3164) Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Reference Issues/PRs
#22406
What does this implement/fix? Explain your changes.
Fixes the notebook style of the example
Any other comments?