Look at the Digits
Part of the Unsupervised Learning section of Coddy's Machine Learning journey. Lesson 43 of 51.
Your last project: 1,797 handwritten scans and no teacher. Over five lessons, you will find groups like these without reading a single label:
Every project starts by looking. A pixel's spread, its std over many scans, shows where writers disagree. Here, over every 7:
spread = X[y == 7].std(axis=0)
print((spread == 0).sum())This prints 15: fifteen pixels are blank in every 7. A pixel that never changes tells a model nothing.
Challenge
MediumStart exploring. The starter loads the scans into X, the digits into y, and sets up a chart.
- Find each pixel's spread over all the scans. Print the busiest pixel's row, column and spread (2 decimals), then how many pixels stay blank in every scan.
- Draw them as an 8 by 8 picture on
ax,cmap="Blues", with a color bar. Show it.
For the 1s alone:
Busiest pixel: row 6, column 5 (spread 6.53)
Blank in every scan: 12 pixelsYours covers all 1,797 scans. Coddy describes your picture. Where do writers disagree most?
Try it yourself
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
# 1,797 handwritten scans: 64 pixels each (8 by 8, ink from 0 to 16) and the digit written
digits = load_digits()
X = digits.data
y = digits.target
fig, ax = plt.subplots()
ax.set_title("Where Writers Disagree")
# 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