{"id":22515478,"url":"https://github.com/kylesmith19091/knearestneighbourfromscratch","last_synced_at":"2025-10-29T20:03:25.765Z","repository":{"id":124214062,"uuid":"325954597","full_name":"KyleSmith19091/KNearestNeighbourFromScratch","owner":"KyleSmith19091","description":"MNIST handwritten digits classifier, implemented from scratch using Eigen","archived":false,"fork":false,"pushed_at":"2021-01-15T10:02:10.000Z","size":11312,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T03:41:29.710Z","etag":null,"topics":["algorithm","eigen-library","knearest-neighbour-algorithm","mnist"],"latest_commit_sha":null,"homepage":"","language":"C++","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/KyleSmith19091.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":"2021-01-01T10:02:51.000Z","updated_at":"2022-01-12T15:24:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"c72d9e97-4ea3-4a23-9e4e-3f2a06c6feca","html_url":"https://github.com/KyleSmith19091/KNearestNeighbourFromScratch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleSmith19091%2FKNearestNeighbourFromScratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleSmith19091%2FKNearestNeighbourFromScratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleSmith19091%2FKNearestNeighbourFromScratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleSmith19091%2FKNearestNeighbourFromScratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KyleSmith19091","download_url":"https://codeload.github.com/KyleSmith19091/KNearestNeighbourFromScratch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245955438,"owners_count":20699908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","eigen-library","knearest-neighbour-algorithm","mnist"],"created_at":"2024-12-07T03:32:43.063Z","updated_at":"2025-10-29T20:03:25.678Z","avatar_url":"https://github.com/KyleSmith19091.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KNearest Neighbour Algorithm\nThis is an implementation of the KNearest Neighbour algorithm in C++, this repo reads data from the MNIST dataset.\nI added a MNIST file parser to read image data and labels. The image data is wrapped in an Image object where the pixel\ndata is stored in a Eigen Matrix to allow for effiecent calculation of the euclidian distance when using the algorithm.\n\n**Caution this project is dependent on the Eigen Library**\n\nType make to create the executable binary and to run the program\n```bash\n$ make\n```\n\nExample Main.cpp\n```c++\n\n#include \"../include/DataHandler.hpp\"\n#include \"../include/KNNAlgo.hpp\"\n#include \u003ciostream\u003e\n\nusing namespace std;\n\nint main(){\n\n    DataHandler dh;\n    // False to specify that it is training dataset\n    dh.prepareData(\"path_image_file\", \"path_label_file\",false);\n    // True to indicate that data is test dataset\n    dh.prepareData(\"path_image_file_test\", \"path_label_file_test\",true);\n\n    double count = 0;\n    double iterNum = 10;\n    KNNAlgo knn;\n\n    for(int i = 0; i \u003c iterNum; i++){\n        bool eval = knn.Classify(dh.get_Image_Data(), dh.get_Test_Image_Data()[i]);\n        if(eval) count++;\n    }\n\n    cout \u003c\u003c \"Accuracy: \" \u003c\u003c (count/iterNum*100) \u003c\u003c \"%\\n\";\n\n    return 0;\n}\n\n```\n\n## What I learned\n- KNearest Neighbour Algorithm\n- Parsing MNIST file\n- Eigen Matrix Library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylesmith19091%2Fknearestneighbourfromscratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkylesmith19091%2Fknearestneighbourfromscratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylesmith19091%2Fknearestneighbourfromscratch/lists"}