Thanks to visit codestin.com
Credit goes to pkg.go.dev

knn

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(left, right *sparseRow) float64

CosineSimilarity between rows

func EuclideanDistance

func EuclideanDistance(left, right *sparseRow) float64

EuclideanDistance between rows

func PearsonCorrelation

func PearsonCorrelation(left, right *sparseRow) float64

PearsonCorrelation between rows

Types

type Classifier

type Classifier struct {
	// contains filtered or unexported fields
}

Classifier provides k-nearest neighbor classification

func New

func New(opts ...Option) *Classifier

New initializes a new k-nearest neighbor classifier unless overridden, binary term weights and k=1 will be used for the created instance

func (*Classifier) Classify

func (c *Classifier) Classify(r io.Reader) (string, error)

func (*Classifier) ClassifyString

func (c *Classifier) ClassifyString(doc string) (string, error)

func (*Classifier) Train

func (c *Classifier) Train(r io.Reader, category string) error

func (*Classifier) TrainString

func (c *Classifier) TrainString(doc string, category string) error

type Option

type Option func(c *Classifier) error

Option provides a functional setting for the Classifier

func K

func K(k int) Option

K provides the value of 'k'

func Similarity

func Similarity(s SimilarityScore) Option

Similarity provides an alternate similarity scoring strategy

func TermIndex

func TermIndex(i *index.TermIndex) Option

TermIndex provides an alternate TermIndex

func Tokenizer

func Tokenizer(t classifier.Tokenizer) Option

Tokenizer provides an alternate document Tokenizer

func WeightScheme

func WeightScheme(s classifier.WeightSchemeStrategy) Option

WeightScheme provides the term weight scheme

type Partitioning

type Partitioning interface {
	// Partition between low and high elements
	Partition(low, high int) int
}

Partitioning indicates that a type can be partitioned and reordered

type SimilarityScore

type SimilarityScore func(left, right *sparseRow) float64

SimilarityScore provides pluggable support for row similarity

type Stack

type Stack []int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL