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) ClassifyString ¶
func (c *Classifier) ClassifyString(doc string) (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 Similarity ¶
func Similarity(s SimilarityScore) Option
Similarity provides an alternate similarity scoring strategy
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