Assignment 1

Handwritten Digit Recognition

GitHub Submission

  1. Your repository must include:

     
    README.md Answers, results, figures, and instructions for running the project
    data_prep.py Dataset download and preprocessing
    train.py Model training and evaluation
    predict.py Load the saved model and predict without retraining
    requirements.txt Required Python packages
    outputs/ Saved model, evaluation results, and figures

4 Buttons

Joystick

Adapt the provided Fashion-MNIST logistic regression example to classify handwritten digits 0–9 using MNIST.

Your tasks:

  • Download and prepare the labeled MNIST dataset.
  • Train a multiclass logistic regression model.
  • Evaluate and explain the results.
  • Publish your code and report on GitHub.

Submission: GitHub repository link. Write your report in README.md.

Handwritten Digit Recognition

Dataset and Preprocessing

 

  1. How many training and test images are there?
  2. What are the image dimensions and class labels?
  3. Why do we convert each image into 784 values?
  4. Why do we divide pixel values by 255?
  5. Why must training and test data remain separate?

Image showing of  :

  • Training and test shapes.
  • One labeled sample image for each digit.

DATA_DIR = Path(kagglehub.dataset_download("oddrationale/mnist-in-csv"))

Answer question in your README

Model and Training

  1. Why does the model use 784 inputs and 10 outputs?
  2. Why do we use CrossEntropyLoss?
  3. What batch size, learning rate, and number of epochs did you use?
  4. How did the training loss change? What does this tell you?

Image showing of  :

  • Model architecture.
  • Training settings.
  • Training loss graph and explanation.

Answer question in your README

Evaluation and Predictions

  1. What test accuracy did you achieve?
  2. How does it compare with the most-frequent-class baseline?
  3. Which digit has the highest recall? Which has the lowest?
  4. Which digit pairs are frequently confused?
  5. What might explain the incorrect predictions?
  6. Does a high test accuracy guarantee correct predictions on camera images? Explain.

Image showing of  :

  • Test and baseline accuracy.
  • Classification report.
  • Confusion matrix.
  • Nine randomly selected test predictions.
  • Three incorrect predictions, if available, with explanations.

Answer question in your README