Skip to content

SurajAdhikari01/DigitRecognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Digit Recognizer

This project is a small neural network built from scratch with NumPy to classify handwritten digits from the Kaggle Digit Recognizer dataset.

Setup

Install the dependencies:

pip install -r requirements.txt

Place the Kaggle train.csv in one of the locations the script already checks, for example:

models/data/train.csv

You can also pass a custom path when running the script:

python models/neural_network.py --data path/to/train.csv

Run

Train the model and generate example prediction images:

python models/neural_network.py

The script will save sample predictions to outputs/.

Results

I ran the model on models/data/train.csv with the default settings in the script and got the following training accuracy progression:

Iteration Accuracy
0 0.1148
500 0.8503
1000 0.8830
1500 0.8974
2000 0.9054
2500 0.9109
3000 0.9151
3500 0.9184
4000 0.9210
4500 0.9236
4950 0.9253

Example predictions from the final run:

  • Index 30: predicted 7, label 7
  • Index 3: predicted 8, label 8
  • Index 50: predicted 8, label 8
  • Index 8: predicted 0, label 0

Generated images:

  • outputs/prediction_30.png
  • outputs/prediction_3.png
  • outputs/prediction_50.png
  • outputs/prediction_8.png

Notes

  • The script uses a simple 2-layer neural network with ReLU and softmax.
  • The training accuracy above is on the training split used by the script, not a separate Kaggle leaderboard score.
  • If you want to run fewer iterations for a quick test, use --iterations.

Dataset

Download the data from Kaggle:

https://www.kaggle.com/competitions/digit-recognizer/data

About

Digit Recognizer using neural network

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages