{"id":26959168,"url":"https://github.com/ryan-rozario/nn-with-knn","last_synced_at":"2025-07-12T11:05:22.677Z","repository":{"id":130198560,"uuid":"214792911","full_name":"ryan-rozario/nn-with-knn","owner":"ryan-rozario","description":"Improving Neural-Network Classifiers Using Nearest Neighbor Partitioning","archived":false,"fork":false,"pushed_at":"2019-11-11T10:11:38.000Z","size":12978,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T22:36:13.758Z","etag":null,"topics":["classification","dimensionality-reduction","evolutionary-computation","knn","neural-network","optimization","paper","particle-swarm-optimization","pso"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryan-rozario.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2019-10-13T09:27:00.000Z","updated_at":"2024-02-02T04:05:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"3bc488a6-f2ed-4062-9f05-178fe5014d68","html_url":"https://github.com/ryan-rozario/nn-with-knn","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":"0.33333333333333337","last_synced_commit":"c42972c02bdb546a139a74dd07efef6087fdd1d3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-rozario%2Fnn-with-knn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-rozario%2Fnn-with-knn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-rozario%2Fnn-with-knn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-rozario%2Fnn-with-knn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryan-rozario","download_url":"https://codeload.github.com/ryan-rozario/nn-with-knn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246939176,"owners_count":20857916,"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":["classification","dimensionality-reduction","evolutionary-computation","knn","neural-network","optimization","paper","particle-swarm-optimization","pso"],"created_at":"2025-04-03T04:37:00.335Z","updated_at":"2025-04-03T04:37:00.816Z","avatar_url":"https://github.com/ryan-rozario.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reducing Dimensionality of data using a Neural Network trained using PSO to apply KNN\n## Paper\nBase Paper: L. Wang, B. Yang, Y. Chen, X. Zhang and J. Orchard, \"Improving Neural-Network Classifiers Using Nearest Neighbor Partitioning,\" in IEEE Transactions on Neural Networks and Learning Systems, vol. 28, no. 10, pp. 2255-2267, Oct. 2017. doi: 10.1109/TNNLS.2016.2580570\n\nURL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=\u0026arnumber=7502076\u0026isnumber=8038919\n\n\nPaper for Particle Swarm Optimization: R. Eberhart and J. Kennedy, “A new optimizer using particle swarm theory,” in Proc. 6th Int. Symp. Micro Mach. Human Sci., 1995 pp. 39–43.\n## Implementation\nA neural network is used to reduce the dimensionality of data, so as to perform KNN faster.\nThis neural network is trained using particle swarm optimization\n\n* [pso](pso.py) contains code for the neural network and training it using pso\n* [knn_code](knn_code.py) conains code for knn to test a neural network for accuracy\n* [final_code](final_code.py) loads the dataset and does k-fold validation\n\n### How the code works\n* k-fold Validation\nDataset -\u003e  Test Set and Training Set\n* Training neural network\nAdjust the weights of the neural network using Particle Swarm Optimization through the training set\n* KNN Accuracy\nTest your model for accuracy using the testing set\n\n## Tasks\n- [x] Code the neural network\n- [x] Code the particle swarm optimizer\n- [x] Code for k-fold validation and knn\n- [x] Test for accuracy on different datasets\n\n## Parameters\nParameters in [pso](pso.py) related to the neural network\n\n* CLASS_NUM : number_of_classes in the dataset\n* ALPHA: discriminant weight\n* NEAREST_NEIGHBOURS: number of nearest neighbours\n* NUMBER_OF_INPUT_NODES: input nodes of neural network should be equal to the number of features\n* NUMBER_OF_HIDDEN_NODES: number of hidden nodes\n* NUMBER_OF_OUTPUT_NODES: number of output nodes should be equal to  dimensions of partition space\n* MAX_GENERATION : maximum number of iterations \n* POPULATION_SIZE: number of indivisuals in a population\n\n\nParameters in [final_code](final_code.py) related to the dataset input\n* FILENAME: path to file\n* class_flag: set the class_flag to -1 if the class label is the last column or set class_flag to 0 if class label is first column\n\n\nBy default you will be asked for number of classes, alpha, number of output nodes, filename, class_flag when you run the program\n\n\n## Datasets Used\nFrom the paper:\nWell-known classification data sets were selected from the UCI machine learning repository (http://archive.ics.uci.edu/ml/) for the experiments, including \n* Ionosphere Data Set(Ionosphere),\n* Wisconsin Breast Cancer Diagnostic Data Set (WBCD),\n* Fertility Data Set (Fertility), \n* Haberman’s Survival Data Set (Haberman), \n* Parkinsons Data Set (Parkinsons), \n* Iris Data Set (IRIS), \n* Wine Data Set (Wine), \n* Contraceptive Method Choice Data Set (CMC),\n* Seeds Data Set (Seeds), \n* Glass Identification Data Set (Glass), \n* Zoo Data Set (Zoo).\n\n## Requirements\n* python3\n* numpy\n* scikit-learn","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-rozario%2Fnn-with-knn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryan-rozario%2Fnn-with-knn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-rozario%2Fnn-with-knn/lists"}