Skip to content

akreal/knn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

k-NN text classifier in Go

k-nearest neighbors text classifier using cosine similarity as distance measure between documents.

Usage

package main

import (
	"fmt"
	"github.com/akreal/knn"
)

func main() {
	knn := knn.NewKNN()

	knn.Train("Hello world!", "class1")
	knn.Train("Hello, hello.", "class2")

	k := 1

	predictedClass := knn.Predict("Say hello!", k)

	fmt.Println(predictedClass)
}

About

k-NN text classifier in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages