Welcome to ML Image Classifier! 🎉 This beginner-friendly machine learning project demonstrates how to build a handwritten digit classifier using Support Vector Machine (SVM) algorithm. The model achieves >95% accuracy on the scikit-learn digits dataset, classifying digits from 0 to 9.
Perfect for:
- 🎓 Machine Learning beginners
- 📚 Students learning image classification
- 🔬 Researchers exploring SVM algorithms
- 💡 Anyone interested in computer vision
- 🚀 Quick Setup: Run in minutes with minimal dependencies
- 📊 High Accuracy: Achieves >95% accuracy on test data
- 📈 Visualization: Beautiful plots showing predictions and confusion matrix
- 🎯 Clean Code: Well-commented and easy to understand
- 📱 Lightweight: Uses only 8x8 pixel images (64 features)
The classifier correctly identifies handwritten digits with high accuracy. Green titles indicate correct predictions, while red indicates misclassifications.
Python |
Scikit-learn |
Matplotlib |
NumPy |
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/ShamsRupak/ML-Image-Classifier.git cd ML-Image-Classifier
-
Install dependencies
pip install -r requirements.txt
-
Run the classifier
python classifier.py
That's it! 🎉 The script will:
- Load the digits dataset
- Train an SVM model
- Display accuracy metrics
- Show sample predictions with matplotlib
Click to expand the algorithm explanation
The script loads the built-in digits dataset from scikit-learn, containing 1,797 samples of 8×8 grayscale images.
- Images are flattened from 8×8 matrices to 64-dimensional vectors
- Data is split into 80% training and 20% testing sets
- Uses Support Vector Machine (SVM) with RBF kernel
- Hyperparameters:
gamma=0.001
,kernel='rbf'
- Trains on 1,437 samples
- Makes predictions on 360 test samples
- Calculates accuracy and generates classification report
- Creates visualizations
The model typically achieves:
- Overall Accuracy: ~97-99%
- Per-digit Precision: >95% for most digits
- Training Time: <1 second on modern hardware
Sample Classification Report
precision recall f1-score support
0 1.00 1.00 1.00 36
1 0.97 0.97 0.97 36
2 1.00 1.00 1.00 36
3 0.97 0.92 0.94 36
4 0.97 1.00 0.99 36
5 0.95 0.97 0.96 36
6 1.00 1.00 1.00 36
7 0.97 0.97 0.97 36
8 0.94 0.94 0.94 36
9 0.94 0.94 0.94 36
accuracy 0.97 360
macro avg 0.97 0.97 0.97 360
weighted avg 0.97 0.97 0.97 360
- Educational Projects: Learn ML fundamentals
- Digit Recognition Apps: Foundation for OCR systems
- Research: Baseline for comparing algorithms
- Hackathons: Quick ML demo project
Contributions are welcome! Feel free to:
- 🐛 Report bugs
- 💡 Suggest new features
- 🔧 Submit pull requests
Want to learn more? Check out these resources:
This project is licensed under the MIT License - see the LICENSE file for details.
Shams Rupak
- GitHub: @ShamsRupak
- Project Link: https://github.com/ShamsRupak/ML-Image-Classifier
Made with ❤️ by Shams Rupak | ⭐ Star this repo if you found it helpful!