{"id":24364500,"url":"https://github.com/markuman/fastknn","last_synced_at":"2025-04-15T17:48:02.631Z","repository":{"id":70098152,"uuid":"50456186","full_name":"markuman/fastKNN","owner":"markuman","description":"Loop-Free KNN algorithm for GNU Octave and Matlab","archived":false,"fork":false,"pushed_at":"2019-01-10T18:21:54.000Z","size":3,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:11:20.471Z","etag":null,"topics":["gnu-octave","knn","matlab","minkowski"],"latest_commit_sha":null,"homepage":null,"language":"MATLAB","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/markuman.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-26T20:13:31.000Z","updated_at":"2024-10-16T00:01:41.000Z","dependencies_parsed_at":"2023-03-11T07:58:51.152Z","dependency_job_id":null,"html_url":"https://github.com/markuman/fastKNN","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/markuman%2FfastKNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markuman%2FfastKNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markuman%2FfastKNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markuman%2FfastKNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markuman","download_url":"https://codeload.github.com/markuman/fastKNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249124800,"owners_count":21216696,"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":["gnu-octave","knn","matlab","minkowski"],"created_at":"2025-01-18T23:53:47.655Z","updated_at":"2025-04-15T17:48:02.625Z","avatar_url":"https://github.com/markuman.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastKNN\n\nLoop-Free KNN algorithm for GNU Octave and Matlab\n\n* Origin: https://git.osuv.de/m/fastknn\n* Pull Mirror: https://gitlab.com/markuman/fastknn\n* Push Mirror: https://github.com/markuman/fastknn\n\n# Dataset\n\nDataset taken from http://www.jiaaro.com/KNN-for-humans/\n\n\n    dataset = [\n      %weight, color, # seeds, type\n      303,     3,      1, 1;\n      370,     1,      2, 2;\n      298,     3,      1, 1;\n      277,     3,      1, 1;\n      377,     4,      2, 2;\n      299,     3,      1, 1;\n      382,     1,      2, 2;\n      374,     4,      6, 2;\n      303,     4,      1, 1;\n      309,     3,      1, 1;\n      359,     1,      2, 2;\n      366,     1,      4, 2;\n      311,     3,      1, 1;\n      302,     3,      1, 1;\n      373,     4,      4, 2;\n      305,     3,      1, 1;\n      371,     3,      6, 2;\n    ];\n\n    % lousy mapping\n    fruit = {'Banana', 'Apple'}; \n    color.index = {'red', 'orange', 'yellow', 'green', 'blue', 'purple'};\n    color.red       = 1;\n    color.orange    = 2;\n    color.yellow    = 3;\n    color.green     = 4;\n    color.blue      = 5;\n    color.purple    = 6;\n\n    UF1 = [301, color.green, 1];\n    UF2 = [346, color.yellow, 4];\n    UF3 = [290, color.red, 2];\n\n\nPlay with the Dataset.\n\n\tnormalize = @(x) (x - min(x)) / max((x - min(x))); % reduce by smallest value\n\n# usage\n\n`[classified, k, dist, idx] = fastKNN(trained, unknown, k, distance)`  \n\n* `classified` - result of KNN\n* `k`  \n  * nargin: the defined `k` \n  * nargout: information which `k` was taken _(...when `k` was automatically determined!)_\n* `dist` - sorted calculated distances\n* `idx`  - Index to map sorted distances `dist` to input dataset `trained`\n* `distance` - default = 2\n  * `distance == 2`: **Minkowski becomes equal Euclidean**\n  * `distance == 1`: **Minkowski becomes equal city block metric**\n  * `else`: **Minkowski distance** -  https://en.wikipedia.org/wiki/Minkowski_distance\n\n\n## default with Euclidean distance and automagical determine of `k` \n\n\t\u003e\u003e fastKNN(dataset, UF1)\n\tans =\n     1\n\t\u003e\u003e fruit(ans)\n\tans = \n\t'Banana'\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkuman%2Ffastknn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkuman%2Ffastknn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkuman%2Ffastknn/lists"}