{"id":16648993,"url":"https://github.com/rohan-bhautoo/digits-recognition-using-neural-network","last_synced_at":"2026-04-21T12:32:43.993Z","repository":{"id":136017641,"uuid":"459062994","full_name":"rohan-bhautoo/Digits-Recognition-using-Neural-Network","owner":"rohan-bhautoo","description":"A machine learning system to categorise one of the UCI digit tasks using Neural Network in Java.","archived":false,"fork":false,"pushed_at":"2022-02-15T21:04:01.000Z","size":871,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T02:31:14.401Z","etag":null,"topics":["algorithm","handwritten-digit-recognition","java","machine-learning","neural-network","uci-machine-learning"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rohan-bhautoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T07:46:38.000Z","updated_at":"2022-02-15T20:34:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"61de86d3-642c-469d-bb4f-27935a419505","html_url":"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rohan-bhautoo/Digits-Recognition-using-Neural-Network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FDigits-Recognition-using-Neural-Network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FDigits-Recognition-using-Neural-Network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FDigits-Recognition-using-Neural-Network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FDigits-Recognition-using-Neural-Network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohan-bhautoo","download_url":"https://codeload.github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FDigits-Recognition-using-Neural-Network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32091873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","handwritten-digit-recognition","java","machine-learning","neural-network","uci-machine-learning"],"created_at":"2024-10-12T09:06:15.972Z","updated_at":"2026-04-21T12:32:43.969Z","avatar_url":"https://github.com/rohan-bhautoo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/Neural-network.png\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eDigits Recognition using Neural Network\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.0-brightgreen.svg\" /\u003e\n  \u003cimg alt=\"Java\" src=\"https://img.shields.io/badge/Java-ED8B00?logo=java\u0026logoColor=white\" /\u003e\n  \u003cimg alt=\"JDK\" src=\"https://img.shields.io/badge/JDK-\u003e=11.0.14-blue.svg\" /\u003e\n\u003c/p\u003e\n\n## Description\n\u003e A machine learning system to categorise one of the UCI digit tasks using Neural Network in Java.\n\n### 🏠 [Homepage](/Digits-Recognition-using-Neural-Network/src/RecognizingHandwrittenDigits/RecognizingHandwrittenDigits.java)\n\n## Prerequisite\n\n### Java Development Kit (JDK) \n\u003e JDK version 11 is used for this project as it includes the JavaFX library. Download it [here](https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html).\n\u003e \n\u003e For Windows:\n```sh\nset JAVA_HOME=\"C:\\[Path to folder]\\Java\\jdk-11.0.14\n```\n\u003e Enter the Environment Variables in System Properties.\n\u003e \n\u003e Add **%JAVA_HOME%\\bin** into Path.\n```sh\n%JAVA_HOME%\\bin\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"400\" src=\"https://github.com/rohan-bhautoo/Point-Of-Sales-System/blob/master/Screenshots/Env%20Variable.png\"\u003e\n\u003c/p\u003e\n\n## Neural Network\n\u003e A neural network-based classifier, called Multi-Layer perceptron (MLP), was used in the project to classify handwritten digits. The MLP consists of three layers which are the input layer, hidden layer and output layer.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/multi-layer-perceptron.jpg\"\u003e\n\u003c/p\u003e\n\n\u003e Each of these layers contain a certain number of nodes which are also called neurons and each node in a layer is connected to all other nodes to the next layer. This can also be referred to as the feed forward network. The number of nodes in the input layer depends upon the number of attributes present in the dataset. For this project, the input attributes are integers in the range ```0..16``` and the last attribute is the class code ```0..9```. The number of nodes in the output layer relies on the number of apparent classes that exist in the dataset. The number of hidden layers is hard to determine as the numbers are selected experimentally. Thereby, the following numbers are given to the first and second hidden layers which can be found in the [RecognizingHandwrittenDigits.java](/Digits-Recognition-using-Neural-Network/src/RecognizingHandwrittenDigits/RecognizingHandwrittenDigits.java) class.\n\n```java\nfinal static int FIRST_HIDDEN_LAYER_NODE_AMOUNT = 26;\nfinal static int SECOND_HIDDEN_LAYER_NODE_AMOUNT = 15;\n```\n\u003e In MLP, the connection between two nodes consists of a weight. During training, process, it learns the accurate weight adjustment which corresponds to each connection. For the learning purpose, it uses a supervised learning technique named as Backpropagation algorithm.\n\n### Hidden Layers\n\u003e Hidden layers of a neural network are just a way to add more neurons in between the input and output layers.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/single-layer-perceptron.jpg\"\u003e\n\u003c/p\u003e\n\n\u003e Different mathematical calculations are implemented to perform the algorithm. First is the dot product function, \n\u003e \n\u003e ![Dot Product Function](https://user-images.githubusercontent.com/47154593/154147044-9a5707a2-a7eb-4b6c-86b1-0a7466cb17bc.png)\n\u003e \n\u003e Each of the m features in the input layer is multiplied with a weight (w1, w2, …, wm) and added all together. Then, the hidden output from the hidden neurons (h1, h2, …, hn) are used as input data that has n features. The dot product is finally performed with 1 set of n weights to get the final output y, in the output layer.\n\n\n### Sigmoid Function\n\u003e The Sigmoid function is also called an activation function, which becomes active to allow input signal Z to pass through the neuron if the input is big enough but it limits the output if the input Z is too small.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/sigmoid-function-curve.png\"\u003e\n\u003c/p\u003e\n\n\u003e The graph above shows when the output Z is larger or equal to 0.5, it outputs 1 else if it is smaller than 0.5, it outputs 0. \n\u003e \n\u003e The sigmoid function introduces non-linearity into the neural network model which means that the output from the neuron, which is the dot product of inputs x and weights w plus bias and then put into a sigmoid function, cannot be represented by a linear combination of the input x. This non-linear function produces a new representation of the original data.\n\n### Single-Layer Perceptron vs Perceptron with Hidden Layer\n\u003e Perceptron with hidden layers were most preferable to implement because a research paper has shown that single-layer perceptron was unable to learn an XOR gate. For example, it cannot understand the logic that the weather has to be either hot or cold, but not both. Logic gates such as AND, OR, NOT, XOR are very important building blocks of any digital system. However, the multi-layer perceptron was able to learn the XOR gate with backpropagation. Hidden layers can twist the problem in a way that makes it easy for the neural network to classify the problem or pattern. This is very useful for the recognition of handwritten digits.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/single-layer-perceptron-with-hidden-layer.jpg\"\u003e\n\u003c/p\u003e\n\n## Using MLP for Recognition of Handwritten Digits\n\u003e The dataset, from the Optical Recognition of Handwritten Digits website, contains 32x32 bitmaps and each of these represent an image of 8x8 pixels. The neural network was implemented in the [NetworkBase.java](/Digits-Recognition-using-Neural-Network/src/RecognizingHandwrittenDigits/NetworkBase.java) class containing 64 nodes in the input layer, 26 in the first hidden layer, 15 in the second hidden layer and 10 in the output layer. The 10 output neurons return in an array where each will be classified a digit from 0 to 9. For example, if the handwritten digit is 0, then the output array will be [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]. If the handwritten digit is 5, the array will be [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]. The neural networks become better by repetitively training them on data and based on the weights in each layer.\n\u003e \n\u003e After training the neural network with data from the [first CSV file](/Digits-Recognition-using-Neural-Network/src/RecognizingHandwrittenDigits/Data/cw2DataSet1.csv), the first 4 hidden neurons will be able to recognize the patterns. Then, the [testing CSV file](/Digits-Recognition-using-Neural-Network/src/RecognizingHandwrittenDigits/Data/cw2DataSet2.csv) is fed to the neural network to trigger the hidden neurons and output the correct digit.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"300\" src=\"https://github.com/rohan-bhautoo/Digits-Recognition-using-Neural-Network/blob/main/Images/Trained-neural-network.jpg\"\u003e\n\u003c/p\u003e\n\n## Usage\n\u003e Compile all the java files using:\n```sh\njavac *.java\n```\n\u003e Then, execute the algorithm\n```sh\njava RecognizingHandwrittenDigits\n```\n\n## Author\n\n👤 **Rohan Bhautoo**\n* Github: [@rohan-bhautoo](https://github.com/rohan-bhautoo)\n* LinkedIn: [@rohan-bhautoo](https://linkedin.com/in/rohan-bhautoo)\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohan-bhautoo%2Fdigits-recognition-using-neural-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohan-bhautoo%2Fdigits-recognition-using-neural-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohan-bhautoo%2Fdigits-recognition-using-neural-network/lists"}