PythonTrain a classifier in the browser/15 min
Which digits get confused?
The task
Graded on the total number of mistakes and the worst pair.
The script trains the closest-example model, predicts the test images, and prints the confusion matrix. The two loops then visit every cell of the matrix: true_digit picks the row and pred_digit picks the column. Two things in the starter may be new:
continuemeans "skip the rest of this turn and go straight to the next one". Here it skips the diagonal cells, which count correct answers, so every cell that reaches the lines below it is a mistake.Nonemeans "nothing yet".worst_trueandworst_predhold None until the loop finds a mistake.
Finish the loop body: add each cell's count to mistakes, and whenever a cell's count is bigger than worst_count, remember that cell, as the comment in the starter describes. The last two lines then print the total and the worst pair.
Sign in to start
Exercises need an account.
It is free. Log in or create one, and every attempt and pass is saved to your progress.