Skip to content

Chaganti-Reddy/Hand-Digit-Recognition

Repository files navigation

Hand Digit Recognition


This is a project in which we are going to create a machine learning model to make prediction of a digit which is writting by hand.


Table of Contents


⚠️ Frameworks and Libraries

  • Pytorch: An open source machine learning framework that accelerates the path from research prototyping to production deployment.
  • Matplotlib : Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
  • Numpy: Caffe-based Single Shot-Multibox Detector (SSD) model used to detect faces
  • Pandas: pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.

📁 Datasets

🔄 Source

This dataset is a builtin dataset in pytorch MNIST dataset available from MNIST database;s page. The dataset may also be downloaded directly by importing torchvision.dataset.


📈 Visualising data


🔥 Probability Measure

To convert the output rows into probabilities, we use the softmax function, which has the following formula:

Equation of Softmax:

$$\Large S(y_i) = \frac{e^{y_i}}{\sum_{j} e^{y_j}}$$


Graph of Softmax:



🚇 Cross-Entropy

Accuracy is often used as an evaluation metric for classification, but not as a loss function. A commonly used loss function for classification problems is the cross-entropy, which has the following formula:

Equation of Cross Entropy:

$$\Large D(\hat{y}, y) = -\sum_{j} y_j \ln{\hat{y}_j}$$


Graph of Cross Entropy:



📖 Data Preprocessing

Data pre-processing is an important step for the creation of a machine learning model. Initially, data may not be clean or in the required format for the model which can cause misleading outcomes. In pre-processing of data, we transform data into our required format. It is used to deal with noises, duplicates, and missing values of the dataset. Data pre-processing has the activities like importing datasets, splitting datasets, attribute scaling, etc. Preprocessing of data is required for improving the accuracy of the model.


🔗 Download

The dataset is now available here !


🔑 Prerequisites

All the dependencies and required libraries are included in the file requirements.txt See here


🚀  Installation

The Code is written in Python 3.7. If you don’t have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after cloning the repository:

  1. Clone the repo
git clone https://github.com/Chaganti-Reddy/Hand-Digit-Recognition.git
  1. Change your directory to the cloned repo
cd Hand-Digit-Recognition
  1. Now, run the following command in your Terminal/Command Prompt to install the libraries required
python3 -m virtualenv my_env

source my_env/bin/activate

pip3 install -r requirements.txt

💡 How to Run

  1. Open terminal. Go into the cloned project directory and type the following command:
python3 Digit-Recognition.py

📂 Directory Tree

├── assets
│   ├── digit5.png
│   ├── entropy.png
│   ├── graph.png
│   ├── home.png
│   ├── softmax-graph.png
│   └── softmax.png
├── data
│   └── MNIST
│       └── raw
│           ├── t10k-images-idx3-ubyte
│           ├── t10k-images-idx3-ubyte.gz
│           ├── t10k-labels-idx1-ubyte
│           ├── t10k-labels-idx1-ubyte.gz
│           ├── train-images-idx3-ubyte
│           ├── train-images-idx3-ubyte.gz
│           ├── train-labels-idx1-ubyte
│           └── train-labels-idx1-ubyte.gz
├── Digit-Recognition.ipynb
├── Digit-Recognition.py
├── LICENSE
├── mnist-logistic.pth
├── Readme.md
└── requirements.txt

🔑 Results

Our Classification Model has successfully predicted the output with an excellent accuracy via PyTorch



👏 And it's done!

Feel free to mail me for any doubts/query :email: chagantivenkataramireddy1@gmail.com


🙋 Citation

You are allowed to cite any part of the code or our dataset. You can use it in your Research Work or Project. Remember to provide credit to the Maintainer Chaganti Reddy by mentioning a link to this repository and her GitHub Profile.

Follow this format:

  • Author's name - Chaganti Reddy
  • Date of publication or update in parentheses.
  • Title or description of document.
  • URL.

❤️ Owner

Made with ❤️  by Chaganti Reddy

👀 License

MIT © Chaganti Reddy