Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

MNIST and QMNIST Image Classification

This project was made for delta ML inductions. This repository contains a detailed machine learning and deep learning implementation. The project focuses on handwritten digit recognition by leveraging both the classic MNIST dataset and its structurally complete extension, QMNIST.


Project Objectives

The goal of this project is to build an optimized computer vision model capable of identifying handwritten digits from 0 to 9. By incorporating both MNIST and QMNIST, the workflow evaluates how well a model generalizes across different distributions of the same underlying task, ensuring robust performance evaluation beyond traditional benchmarks.


Dataset Characteristics and Pipeline

1. MNIST Dataset

The original Modified National Institute of Standards and Technology (MNIST) dataset is a standard benchmark in computer vision.

  • Training Set: 60,000 images
  • Testing Set: 10,000 images
  • Data Format: 28x28 pixel grayscale matrices, where pixel values range from 0 (white background) to 255 (black foreground ink).

2. QMNIST Dataset

The QMNIST dataset was developed to address the missing source data from the original MNIST test set. It reconstructs the preprocessing steps applied to the original NIST database to match MNIST as closely as possible, while providing a vastly expanded evaluation suite.

  • Testing Set: 60,000 images (providing 50,000 extra testing images not found in the standard MNIST dataset).
  • Metadata: Contains additional label information, such as the original NIST sample index, writer ID, and digit class, allowing for granular error analysis.

Detailed Technical Workflow

Phase 1: Data Acquisition and Preprocessing

  • Loading: Importing raw pixel arrays for both MNIST and QMNIST.
  • Normalization: Scaling the integer pixel values from the range [0, 255] to a floating-point range of [0.0, 1.0]. This stabilizes gradient calculations during backpropagation.
  • Reshaping: Formating data tensors based on the model architecture. For Multi-Layer Perceptrons (MLPs), the 28x28 matrices are flattened into a 1D vector of 784 features. For Convolutional Neural Networks (CNNs), they are reshaped to (28, 28, 1) to preserve spatial dimensions.

Phase 2: Exploratory Data Analysis (EDA)

  • Visual Verification: Plotting random selections of digits using custom grid layouts to ensure integrity across both datasets.
  • Class Distribution Check: Verifying that the target labels (0-9) are uniformly distributed across the datasets to prevent the model from developing a class bias.

Phase 3: Model Architecture Configuration

The notebook tests and optimizes neural network structures designed for spatial pattern extraction:

  • Feature Extraction Layers: Utilizing 2D Convolutional layers (Conv2D) to automatically capture local spatial features like edges, curves, and intersections, paired with Rectified Linear Unit (ReLU) activation functions.
  • Dimensionality Reduction: Applying Max Pooling (MaxPooling2D) layers to reduce the spatial size of the feature maps, reducing computational load and preventing overfitting.
  • Classification Head: Flattening the final feature maps and passing them through Fully Connected (Dense) layers, ending with a Softmax activation function over 10 output nodes to yield class probabilities.

Phase 4: Model Training and Optimization

  • Loss Function: Implementing CategoricalCrossentropy or SparseCategoricalCrossentropy to measure the difference between predicted probability distributions and true labels.
  • Optimizer: Utilizing adaptive gradient algorithms (such as Adam or RMSprop) to update model weights efficiently.
  • Validation Split: Reserving a segment of the training data to monitor for overfitting during training epochs.

Phase 5: Rigorous Evaluation

The model's generalization capabilities are thoroughly vetted using both testing distributions:

  • Standard Evaluation: Calculated against the traditional 10,000-image MNIST test set.
  • Extended Evaluation: Calculated against the 60,000-image QMNIST test set to ensure the accuracy metrics remain stable when exposed to a larger pool of unseen variations.
  • Performance Metrics: Generating a Confusion Matrix, Precision, Recall, and F1-Score profiles to pinpoint which digits (e.g., misclassifying 4s as 9s, or 3s as 8s) cause the highest error rates.

Development Environment

The following dependencies are required to run the pipeline:

  • Core Language: Python 3.x
  • Numerical & Data Processing: NumPy, Pandas
  • Data Visualization: Matplotlib, Seaborn
  • Machine Learning & Evaluation: Scikit-Learn
  • Deep Learning Engine: TensorFlow/Keras or PyTorch (depending on final implementation choice)

Setup and Reproduction

1. Repository Setup

git clone [https://github.com/your-username/repository-name.git](https://github.com/your-username/repository-name.git)
cd repository-name

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages