Skip to content

Tutorial example code lacking context #13566

@jramirezpr

Description

@jramirezpr

on:
https://scikit-learn.org/stable/tutorial/statistical_inference/unsupervised_learning.html
the code

import matplotlib.pyplot as plt

from skimage.data import coins
from skimage.transform import rescale

from sklearn.feature_extraction.image import grid_to_graph
from sklearn.cluster import AgglomerativeClustering


# #############################################################################
# Generate data
orig_coins = coins()

# Resize it to 20% of the original size to speed up the processing
# Applying a Gaussian filter for smoothing prior to down-scaling
# reduces aliasing artifacts.
smoothened_coins = gaussian_filter(orig_coins, sigma=2)
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect")

X = np.reshape(rescaled_coins, (-1, 1))

# #############################################################################
# Define the structure A of the data. Pixels connected to their neighbors.
connectivity = grid_to_graph(*rescaled_coins.shape)

Is not completely connected to the example it is trying to illustrate. Looks like it was planning to
plot the image but this is never done(same with AgglomerativeClustering), also the gaussian_filter is not imported. This code snippet should be completed, and its relationship with agglomerative clustering fleshed out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationEasyWell-defined and straightforward way to resolvegood first issueEasy with clear instructions to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions