This repository contains a Jupyter Notebook that implements and compares three ML approaches for the MNIST handwritten-digit dataset: the Perceptron Learning Algorithm (PLA), Softmax (logistic) Regression, and a Linear Regression baseline.
digit_mnist_classification.ipynb— main notebook with data loading, training, evaluation, and visualization.
- Python 3.8+ recommended
- Packages used in the notebook:
numpyscikit-learnmatplotlibtqdm
Install the packages with pip:
python -m pip install --upgrade pip
python -m pip install numpy scikit-learn matplotlib tqdmIf you plan to run in Google Colab, most packages are preinstalled; you can still run the pip command in a Colab cell to ensure latest versions.
Local Jupyter (recommended):
# install requirements (see above)
python -m pip install numpy scikit-learn matplotlib tqdm
# start notebook server
jupyter notebook digit_mnist_classification.ipynbOpen the notebook and run cells sequentially. The notebook is annotated and divided into logical sections: data prep, PLA, Softmax, Linear Regression, and evaluation.
Google Colab:
Use the badge or open directly: Open in Colab
Key top-level variables in the notebook that control training:
NUM_OF_ITERATION_PLA— iterations for the Perceptron training loop.NUM_OF_ITERATION_SOFTMAX— iterations for Softmax gradient descent.
Change those variables near the top of the notebook to adjust trade-offs between runtime and accuracy. Note: higher iteration counts increase training time significantly.
The notebook computes per-model accuracy, confusion matrices, and a summary table of accuracy vs. training time. See the Summary section inside the notebook for example historical results (different iteration counts tested).
- The MNIST dataset is fetched with
sklearn.datasets.fetch_openml— this requires internet on first run. - Training PLA in a one-vs-all setup can be slow for large iteration counts; consider reducing
NUM_OF_ITERATION_PLAfor quick experiments.
This repository currently has no formal license. If you intend to share or publish the code, consider adding a license (for example, MIT). If you want, I can add an LICENSE file with MIT text.
If you'd like, I can also add a minimal requirements.txt, an explicit LICENSE file, or insert the summary table from the notebook into this README. Tell me which of those you'd like next.