This is a Polynomial Regression model that learns to classify hand-written digits from the MNIST dataset. Try different values for 'lambda' and 'p' to experiment with output.
- Python
- Numpy
- Matplotlib
git clone https://github.com/chivington/MNIST-Polynomial-Regression-Classifier.git
Change into the directory and run:
python mnist_polynomial_regression_classifier.py
Open the file 'mnist_polynomial_regression_classifier.py' and edit the hyperparameters 'lambda' (named "lambd" in the code since "lambda" is a reserved keyword in the Python programming language) and the vector 'p' to experiment with finding optimal values for accuracy and quick convergence. The program will:
- Load the MNIST dataset.
- Split it into "training," "validation," and "testing" sets.
- Display a random digit from the training set.
- Train the model on the various p-values, displaying the training error, test error and training time.
- Display a plot of the training errors, validation errors, training times, with respect to the various p-values.
- Display a digit from the test set, along with it's classification and label.
- Print out the final training and test set errors to the terminal.
- End.
Large values of 'p' will result in increased training times. For my Surface Book (2.81ghz i7, 8gb ram, GeForce 940m), a p-value of 7500 takes ~374 seconds to train and achieves ~4.48% testing error rate, as shown in the images below. The datasets needed to train and make predictions are included and you should not have to move or rename any files or filenames in the code.
Feel free to ask me questions on GitHub or LinkedIn
Not currently accepting outside contributors, but feel free to use as you wish.
There is no license associated with this content.