https://github.com/johnstonskj/rml-knn
K-Nearest Neighbor implementation in Racket.
https://github.com/johnstonskj/rml-knn
Last synced: 14 days ago
JSON representation
K-Nearest Neighbor implementation in Racket.
- Host: GitHub
- URL: https://github.com/johnstonskj/rml-knn
- Owner: johnstonskj
- License: mit
- Created: 2018-06-28T23:14:47.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T16:20:29.000Z (about 1 year ago)
- Last Synced: 2025-02-12T23:33:40.259Z (2 months ago)
- Language: Racket
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-racket - rml-knn - This Package is part of a set of packages implementing machine learning capabilities for Racket. This particular package implements the K-Nearest Neighbor approach for classification. (Machine Learning)
README
# Racket Machine Learning - *k*-Nearest Neighbor
[](https://github.com/johnstonskj/rml-knn/releases)
[](https://www.travis-ci.org/johnstonskj/rml-knn)
[](https://coveralls.io/github/johnstonskj/rml-knn?branch=master)
[](http://pkgs.racket-lang.org/package/rml-knn)
[](http://docs.racket-lang.org/rml-knn/index.html)
[](https://github.com/johnstonskj/rml-core/stargazers)
This package implements a *k*-NN approach for the Racket Machine Learning
package set, based on an article by
[Tony Baker](https://spin.atomicobject.com/2013/05/06/k-nearest-neighbor-racket/).
The `classifier` module provides a relatively simple classification approach by
determining the Euclidean distance between an individual and a set of pre-
classified training data. This package relies on the
[rml-core](https://github.com/johnstonskj/rml-core) package and provides a
*classifier* for use with the `rml/classify` module.# Modules
* `classifier` - Support for classifying an individual against a trained data set.
# Examples
```scheme
(require rml/data
rml/individual
rml/results
rml-knn/classifier); construct dataset ...
(define iris (make-individual "sepal-length" 6.3
"sepal-width" 2.5
"petal-length" 4.9
"petal-width" 1.5
"classification" "Iris-versicolor"))(define C (make-result-matrix dataset))
(record-result C
(hash-ref iris "classification")
(first ((make-knn-classifier 5) dataset iris)))
```The function `make-knn-classifier` returns the classification function
itself, this conforms to the `classifier/c` contract from the `rml/classify`
module.[](https://racket-lang.org/)