Image Classification · Study

English translation

Topics covered

Inspect misclassified samples behind image classification accuracy to examine the effects of preprocessing and data splitting.

The structure of image samples

The small grayscale images in load_digits also have pixel arrays, ground truth, and separate samples. First define normalization and the training/evaluation split, then inspect actual misclassified images.

What to Examine after Average Accuracy

Examine which classes or blurred inputs account for errors. Evaluate results with small added noise as a separate condition, and keep transformed samples and their originals from being mixed across training and evaluation sets.

Worked example

Use Classes 0–4 from the 8×8 images in sklearn load_digits, which requires no external download. Use a stratified 70/30 split with seed=7.

from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
D=load_digits();mask=D.target<5;X=D.data[mask];y=D.target[mask]
Xtr,Xte,ytr,yte=train_test_split(X,y,test_size=.3,random_state=7,stratify=y)
scaler=StandardScaler().fit(Xtr);clf=LogisticRegression(max_iter=1000).fit(scaler.transform(Xtr),ytr)
print(clf.score(scaler.transform(Xte),yte))
1.0

Reference example

View more examples

Fashion-MNIST Example · Image Arrays and Flatten

Refer to the image display and array shape in the introduction. This activity uses 8×8 images from load_digits.