This repository contains a comprehensive comparison of various machine learning classification algorithms on the Sklearn Digits dataset, evaluating both default and hyperparameter-tuned versions of each model. The project demonstrates a complete end-to-end machine learning workflow for classifying handwritten digits using the Digits Dataset from Scikit-learn.
- Dataset: Digits dataset (8x8 images of handwritten digits 0–9).
- Techniques:
- Data loading, normalization, and preprocessing
- Training 8 classifiers (default and hyperparameter-tuned)
- Model evaluation using balanced accuracy, precision, recall, F1-score, ROC AUC
- Visualizations (ROC curves, confusion matrices)
- Gradient Boosting (Friedman, 2001)
- AdaBoost (Freund & Schapire, 1997)
- Random Forest (Breiman, 2001)
- Decision Tree (Quinlan, 1986)
- Logistic Regression (Cox, 1958)
- K-Nearest Neighbors (Cover & Hart, 1967)
- Gaussian Naive Bayes (Mitchell, 1997)
- Support Vector Machine (Cortes & Vapnik, 1995)
- Python 3.x
- Scikit-learn
- NumPy
- Pandas
- Matplotlib
- Seaborn
Several Hyperparameters were used for model tuning
- Balanced Accuracy
- Macro-averaged ROC AUC
- Precision, Recall, F1-Score
- Confusion Matrices
Both default and tuned models were evaluated, and performance was compared visually through consolidated ROC plots.
Example ROC curve visualization:
The performance evaluation of eight classification models on the Sklearn Digits dataset reveals exceptional results across multiple metrics. Gradient Boosting, Random Forest, Logistic Regression, K-Nearest Neighbors, and Support Vector Machine consistently demonstrated superior performance, achieving balanced accuracy, precision, recall, and F1-scores exceeding 0.97 in their tuned configurations. The comparison between default and tuned models highlights significant improvements through hyperparameter optimization, particularly for AdaBoost, which transformed from one of the lowest performers (0.78-0.81) to one of the strongest (0.96). Decision Trees consistently underperformed relative to other algorithms, while Gaussian Naive Bayes showed moderate improvement after tuning but remained below the top performers.
These results reinforce several theoretical foundations of machine learning across all tested models. The superior performance of ensemble methods (Gradient Boosting, Random Forest, AdaBoost after tuning) validates the mathematical principles behind boosting (sequential error correction) and bagging (variance reduction through randomized sampling). Support Vector Machine's effectiveness demonstrates its theoretical advantage in finding optimal decision boundaries in high-dimensional spaces, while Logistic Regression's strong performance validates its probabilistic approach to classification despite its relative simplicity. The comparative weakness of Decision Trees highlights their known vulnerability to overfitting without pruning or ensemble techniques. K-Nearest Neighbors' solid results reflect the power of non-parametric, instance-based learning when working with well-clustered data. The relative struggles of Gaussian Naive Bayes illustrate the limitations of its independence assumption between features, particularly problematic for spatially correlated image data. The consistent improvement post-tuning across all algorithms confirms optimization theory's central role in practical machine learning. This comprehensive comparison illustrates how algorithm selection should be guided by understanding both data characteristics and each model's theoretical underpinnings, with tuned parameters bridging the gap between theory and optimal performance.
- Ensemble methods (Gradient Boosting, Random Forest) consistently performed best
- Hyperparameter tuning significantly improved performance, especially for AdaBoost
- Decision Trees consistently underperformed compared to other algorithms
- Top models achieved balanced accuracy, precision, recall, and F1-scores exceeding 0.97
- Clone this repository:
git clone https://github.com/Lummy-A/machine-learning-digits-classification.git cd machine-learning-digits-classification
- Navigate into the project directory:
cd digits-classification-ml
- Set up a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use 'venv\Scripts\activate'
- Install the required dependencies: Install all the Python libraries listed in the requirements.txt file by running:
pip install -r requirements.txt
- Open the Jupyter notebook: Launch Jupyter Notebook to open the project:
jupyter notebook group_notebook.ipynb
- Run the notebook: Once the notebook opens, run the cells in order to load the data, train the models, and evaluate them. The results, including metrics and plots, will appear as you go through the notebook.
For running in Google Colab (Optional): If you prefer not to run it locally and want to try it on Google Colab, just follow these steps:
- Open Google Colab.
- Click on File → Open notebook.
- Select the GitHub tab and enter your repository URL: https://github.com/Lummy-A/machine-learning-digits-classification
- Open the notebook from the list and run it just like you would in Jupyter Notebook.
This project is a collaboration between
- Lum Apeh Temukum
- Sagar Prajapat
- Nanditha Suresh Kumar
- Kedar Vishwanath Kalyani
We welcome contributions! If you’d like to help improve this project, follow these steps:
- Fork this repository.
- Clone your fork locally.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
Feel free to open an issue for any questions, suggestions, or bugs!
This project cites academic papers and textbook references for each classification method, evaluation technique, and model improvement strategies. (Full reference list is included inside the project folder.)
Generative AI (ChatGPT) was minimally used for minor code optimization suggestions (e.g., improving ROC plot styles and DataFrame indexing). All main logic, model building, evaluation, and tuning were manually implemented.
This project is licensed under the MIT License - see the LICENSE file for details.