Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 10 — Assignment Project: Evaluating and Training a Digit Reader

Open in Colab

Overview

A postal service wants to read handwritten digits (scikit-learn’s load_digits: 1 797 images of 8 × 8 pixels). Before choosing a model, they want to know how sure any reported accuracy is, which model is really better, whether more data would help, and whether the training of a neural network can be trusted.

PartTaskPoints
AHow much does one split vary?20
BComparing three models on the same folds20
CLearning curves20
DControlling the training of a network25
EReport15

Rule: hold out a stratified 20% test set now (random_state=0) and use it only once, in Part D.


Part A — How Much Does One Split Vary? (20 points)

  1. For the SVM, split the development set 30 times (80/20, stratified, seeds 0–29), and record the validation accuracy of each split. Report the minimum, the maximum and the standard deviation.

  2. Run 5-fold stratified cross-validation on the development set. Report the mean and the standard deviation of the fold scores.

  3. In two sentences: what does Part A tell you about comparing two models whose single-split accuracies differ by 0.005?

Your answer:


Part B — Comparing Three Models on the Same Folds (20 points)

  1. Score the three models with RepeatedStratifiedKFold(n_splits=5, n_repeats=5, random_state=0), the same splitter object for all.

  2. For each pair of models, report the mean paired difference, its standard deviation and the share of folds won.

  3. Which model would you keep, and how confident are you?

Your choice and its justification:


Part C — Learning Curves (20 points)

  1. Plot learning curves (training sizes 10% to 100% of the development set, 5-fold stratified) for logistic regression and the SVM.

  2. For each, say whether the model is limited by bias or by variance, and whether doubling the data would be worth its cost.

Your reading of the curves:


Part D — Controlling the Training of a Network (25 points)

An MLPClassifier(hidden_layer_sizes=(128,), alpha=0, random_state=0) trained one epoch at a time with partial_fit on 80% of the development set, validated on the other 20%.

  1. Train for 100 epochs with learning_rate_init 0.00001, 0.01 and 1.0. Plot the training and validation losses of each. Diagnose each curve with the vocabulary of Section 10.7.

  2. For the good learning rate, apply early stopping with a patience of 10 epochs (your own loop: keep a copy of the network at its best validation loss, with copy.deepcopy).

  3. Report the test accuracy of the early-stopped network, once.

Your diagnoses:


Part E — Report (15 points)

Half a page for the postal service: the model you recommend; its expected accuracy with its uncertainty; what the learning curves say about collecting more data; and how the network’s training is controlled.

Grading Rubric

CriterionExcellentAdequateInsufficient
A (20)spread measured and interpretednumbers onlymissing
B (20)paired differences, a justified choicemeans onlydifferent folds per model
C (20)curves read correctly for both modelscurves without readingmissing
D (25)three diagnoses, early stopping implemented, test used oncecurves onlytest set used to choose
E (15)clear, with uncertaintyincompletemissing