Home

Awesome

Racket Machine Learning - k-Nearest Neighbor

GitHub release Travis Status Coverage Status raco pkg install rml-core Documentation GitHub stars MIT License

This package implements a k-NN approach for the Racket Machine Learning package set, based on an article by Tony Baker. 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 package and provides a classifier for use with the rml/classify module.

Modules

Examples

(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.

Racket Langaueg