Learning Without Labels
Part of the Unsupervised Learning section of Coddy's Machine Learning journey. Lesson 1 of 51.
Every row so far came with its answer, a label. Most data has none. Unsupervised learning finds structure in the rows alone, like these cafe visits:
Similar rows sit close together, and a group of them is a cluster. Nobody told the model about coffees or laptops. It found three groups; people named them.
Shops find kinds of customers this way; by this chapter's end, so will you. No y, only X: the model learns the data's own shape.
Challenge
EasyA fish farm tells trout ages apart by length: each year's fish form a group. lengths holds 36 trout in cm, shortest first; the program reads gap.
- Walk the lengths. A trout more than
gapcm longer than the one before starts a new group. - Print how many groups, then each group's shortest and longest trout and its count.
For another pond and a gap of 2:
Groups: 2
8.5 to 13.9 cm: 15 trout
17.4 to 22.0 cm: 11 troutTry it yourself
# 36 trout from one pond, length in cm, shortest first
lengths = [9.8, 10.4, 10.9, 11.3, 11.6, 12.0, 12.2, 12.7, 13.1, 13.4, 14.0, 14.6,
18.2, 18.9, 19.3, 19.8, 20.1, 20.4, 20.6, 21.0, 22.8, 23.0, 23.3, 23.5, 23.7, 23.9,
26.5, 27.1, 27.6, 28.0, 28.3, 28.9, 29.4, 29.8, 30.4, 31.0]
gap = float(input())
# Write your code below
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Unsupervised Learning
1Finding Groups
Learning Without LabelsMeasuring SimilarityK-Means by HandK-Means in scikit-learnRecap: Gym Members7PCA in Practice
Seeing 64 DimensionsComponents as PatternsCompress and RebuildPCA Before a ModelRecap: Face Scanner10Project: Digit Explorer
Look at the DigitsShrink with PCACluster the DigitsName the ClustersFind the Odd OnesPractice on your own: Online Python compiler