Skip to content

ShamsRupak/ML-Image-Classifier

Repository files navigation

🤖 ML Image Classifier - Handwritten Digit Recognition

Python Scikit-learn License Contributions GitHub Stars

Scikit-learn Logo

📋 Overview

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

✨ Features

  • 🚀 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)

🖼️ Sample Output

Sample Predictions

The classifier correctly identifies handwritten digits with high accuracy. Green titles indicate correct predictions, while red indicates misclassifications.

🛠️ Tech Stack

Python
Python
Scikit-learn
Scikit-learn
Matplotlib
Matplotlib
NumPy
NumPy

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

  1. Clone the repository

    git clone https://github.com/ShamsRupak/ML-Image-Classifier.git
    cd ML-Image-Classifier
  2. Install dependencies

    pip install -r requirements.txt
  3. 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

📊 How It Works

Click to expand the algorithm explanation

1. Data Loading 📥

The script loads the built-in digits dataset from scikit-learn, containing 1,797 samples of 8×8 grayscale images.

2. Data Preprocessing 🔧

  • Images are flattened from 8×8 matrices to 64-dimensional vectors
  • Data is split into 80% training and 20% testing sets

3. Model Training 🤖

  • Uses Support Vector Machine (SVM) with RBF kernel
  • Hyperparameters: gamma=0.001, kernel='rbf'
  • Trains on 1,437 samples

4. Evaluation 📈

  • Makes predictions on 360 test samples
  • Calculates accuracy and generates classification report
  • Creates visualizations

📈 Performance Metrics

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

🎯 Use Cases

  • Educational Projects: Learn ML fundamentals
  • Digit Recognition Apps: Foundation for OCR systems
  • Research: Baseline for comparing algorithms
  • Hackathons: Quick ML demo project

🤝 Contributing

Contributions are welcome! Feel free to:

  • 🐛 Report bugs
  • 💡 Suggest new features
  • 🔧 Submit pull requests

📚 Learning Resources

Want to learn more? Check out these resources:

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

Shams Rupak


Made with ❤️ by Shams Rupak | ⭐ Star this repo if you found it helpful!

Releases

No releases published

Packages

No packages published

Languages