This repository implements and presents the accuracy of various machine learning approaches. Specifically in the classification of a dataset generated from MNIST images, where two digits are vertically stacked (56x28) and labeled by the sum of the constituent digits. It first evaluates the performance of a fully connected neural network before comparing it to the alternative methods, each with relative strengths and weaknesses in handling the highly-dimensional dataset.
This repository forms part of the submission for the MPhil in Data Intensive Science's M1 Machine Learning Course at the University of Cambridge.
The notebooks in this repository serve as walkthroughs for the analysis performed. They include derivations of the mathematical implementations, explanations of key choices made, and present the main results. Four notebooks are provided:
| Notebook | Description |
|---|---|
| Notebook 1 | Constructs the training, validation, and test datasets by combining MNIST digits into structured (56×28) images. Implements a fully connected neural network with hyperparameter optimisation, training history, and performance metrics. This notebook establishes the performance benchmark for all subsequent models. |
| Notebook 2 | Investigates alternative machine learning approaches including Support Vector Machines, Decision Trees, Random Forests, and AdaBoost. Includes hyperparameter tuning and a detailed comparison of classification performance against the neural network baseline. |
| Notebook 3 | Examines the performance of weak linear classifiers trained on both combined (56×28) images and on individual (28×28) digits. The latter approach uses probability convolution to infer the sum. |
| Notebook 4 | Applies dimensionality reduction - namely t-distributed Stochastic Neighbor Embedding (t-SNE) to visualise high-dimensional features. Compares embedding layer representations to visualise the isolation and cohesion of these structures in their original high dimensional space. |
The trained models—including the fully connected neural network and the weak linear classifiers—are saved in the Results directory to support reproducibility and enable further analysis or downstream use.
To run the notebooks, please follow these steps:
Clone the repository from the remote repository to your local machine.
git clone https://github.com/JacobTutt/ML_mnist.gitUse a clean virtual environment to avoid dependency conflicts.
python -m venv env
source env/bin/activate # For macOS/Linux
env\Scripts\activate # For WindowsNavigate to the repository’s root directory and install the package dependencies:
pip install -r requirements.txtTo ensure the virtual environment is recognised within Jupyter notebooks, set up a kernel:
python -m ipykernel install --user --name=env --display-name "MNIST ML"Open the notebooks and select the created kernel (MNIST ML) to run the code.
- The associated project report can be found under Project Report.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions, run into issues, or just want to discuss the project, feel free to:
- Open an issue on the GitHub Issues page.
- Reach out to me directly via email.
This project is maintained by Jacob Tutt