{"id":21073742,"url":"https://github.com/chouffe/clj-knn","last_synced_at":"2025-08-22T11:06:44.802Z","repository":{"id":148673631,"uuid":"54080403","full_name":"Chouffe/clj-knn","owner":"Chouffe","description":"KNN implementation in Clojure","archived":false,"fork":false,"pushed_at":"2016-03-18T00:07:32.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T22:23:41.566Z","etag":null,"topics":["clojure","machine-learning"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chouffe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-03-17T01:58:20.000Z","updated_at":"2020-04-23T16:54:58.000Z","dependencies_parsed_at":"2023-05-28T15:30:16.610Z","dependency_job_id":null,"html_url":"https://github.com/Chouffe/clj-knn","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/Chouffe%2Fclj-knn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2Fclj-knn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2Fclj-knn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2Fclj-knn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chouffe","download_url":"https://codeload.github.com/Chouffe/clj-knn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515511,"owners_count":20303258,"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":["clojure","machine-learning"],"created_at":"2024-11-19T19:02:32.929Z","updated_at":"2025-03-14T03:21:30.413Z","avatar_url":"https://github.com/Chouffe.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-knn\n\nImplementation of k-nearest neighbors in Clojure.\n\n### Regression\n\n```\n(def X\n  [[1 6]\n   [2 4]\n   [3 7]\n   [6 8]\n   [7 1]\n   [8 4]])\n\n(def y [7 8 16 44 50 68])\n(def data (make-data X y))\n\n(assert (= 8 (regression 1 euclidean data [4 2])))\n(assert (= 42 (regression 3 euclidean data [4 2])))\n(assert (= 29 (regression 1 manhattan data [4 2])))\n(assert (= 71/2 (regression 3 manhattan data [4 2])))\n(assert (= 171/5 (regression-2 3 manhattan data [4 2])))\n(assert (\u003c= 37 (regression-2 3 euclidean data [4 2]) 38))\n```\n\n### Classification\n\n```\n(def X\n  [[1 6]\n   [2 4]\n   [3 7]\n   [6 8]\n   [7 1]\n   [8 4]])\n\n(def y-class [:slow :slow :fast :fast :fast :light-speed])\n(def data-class (make-data X y-class))\n\n(assert (= :slow (classify 1 euclidean data-class [4 2])))\n(assert (= :slow (classify 3 euclidean data-class [4 2])))\n(assert (= :fast (classify 3 manhattan data-class [5 6])))\n(assert (= :fast (classify 3 euclidean data-class [5 6])))\n```\n\n## knn\n\nk-NN is a type of instance-based learning, or lazy learning, where the function is only approximated locally and all computation is deferred until classification. The k-NN algorithm is among the simplest of all machine learning algorithms.\n\nThe following distance metrics are provided:\n* Euclidean\n* Taxicab/Manhattan\n\nThe k-nn implementation is simple to extend by providing your own distance metrics (Should meet the [Mercer's Conditions](https://en.wikipedia.org/wiki/Mercer%27s_condition)).\n\nIt currently supports the following prediction policies:\n* Classification\n  * Mode\n* Regression\n  * Mean\n  * LWR (Locally Weighted Regression)\n\n## License\n\nCopyright © 2016 Arthur Caillau\n\nDistributed under the Eclipse Public License either version 1.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchouffe%2Fclj-knn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchouffe%2Fclj-knn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchouffe%2Fclj-knn/lists"}