A deep learning project that recognizes handwritten digits (0–9) using an Artificial Neural Network (ANN) built with TensorFlow/Keras. The model is trained on the Kaggle Digit Recognizer dataset and demonstrates the complete machine learning workflow, from data preprocessing to prediction.
Handwritten digit recognition is a fundamental problem in computer vision with applications in optical character recognition (OCR), postal mail sorting, bank cheque processing, and document digitization.
In this project, a feedforward Artificial Neural Network (ANN) is trained to classify grayscale images of handwritten digits into one of ten classes (0–9). The implementation covers data preprocessing, model development, training, validation, and prediction.
This project uses the Digit Recognizer dataset available on Kaggle.
Dataset Link:
https://www.kaggle.com/competitions/digit-recognizer/data
Training Dataset
- 42,000 labeled images
- Dataset shape: (42000, 785)
- First column contains the digit label (0–9)
- Remaining 784 columns represent pixel values of a 28 × 28 grayscale image
Test Dataset
- 28,000 unlabeled images
- Dataset shape: (28000, 784)
The following preprocessing steps are performed:
- Load the dataset using Pandas
- Check for missing values
- Separate image pixels and labels
- Normalize pixel values to the range [0,1]
- One-hot encode class labels
- Split the training data into 80% training and 20% validation
The classifier is a fully connected Artificial Neural Network consisting of:
Input (28 × 28 × 1)
│
Flatten
│
Dense (128, ReLU)
│
Dense (64, ReLU)
│
Dense (10, Softmax)
- Optimizer: Adam
- Loss Function: Categorical Crossentropy
- Activation Functions: ReLU and Softmax
- Evaluation Metric: Accuracy
- Python
- TensorFlow / Keras
- NumPy
- Pandas
- Matplotlib
- Scikit-learn
Clone the repository:
git clone https://github.com/Programiz-007/Handwritten-Digit-Classifier-using-NN.git
cd Handwritten-Digit-Classifier-using-NNInstall the required dependencies:
pip install tensorflow pandas numpy matplotlib scikit-learnOpen and run the notebook:
Handwritten_Digit_Recognition.ipynb
or launch Jupyter Notebook:
jupyter notebookHandwritten-Digit-Classifier-using-NN/
│
├── HandwrittenDigitClassifer_NN.ipynb
└── README.md
The trained model successfully classifies handwritten digits with high accuracy on the validation dataset. This project demonstrates the complete workflow of:
- Data preprocessing
- Neural network training
- Multi-class image classification
- Model evaluation
- Prediction on unseen handwritten digits
- Replace the ANN with a Convolutional Neural Network (CNN)
- Add support for custom handwritten digit images
- Deploy the model using Streamlit or Flask
- Save and reload trained models for inference
- Kaggle: Digit Recognizer Dataset — https://www.kaggle.com/competitions/digit-recognizer/data
This project is intended for educational and learning purposes. Feel free to fork, modify, and extend it for your own projects.