Documentation
¶
Overview ¶
Package knn implement the K Nearest Neighbor using Euclidian to compute the distance between samples.
Index ¶
Constants ¶
View Source
const (
// TEuclidianDistance used in Input.DistanceMethod.
TEuclidianDistance = 0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct { // DistanceMethod define how the distance between sample will be // measured. DistanceMethod int // ClassIdx define index of class in dataset. ClassIdx int // K define number of nearset neighbors that will be searched. K int // AllNeighbors contain all neighbours AllNeighbors Neighbors }
Input parameters for KNN processing.
func (*Input) ComputeEuclidianDistance ¶
ComputeEuclidianDistance compute the distance of instance with each sample in dataset `samples` and return it.
type Neighbors ¶
type Neighbors struct { // Dataset contain the data in neighbors dsv.Dataset // Distance value Distances []float64 }
Neighbors is a mapping between sample and their distance. This type implement the sort interface.
func (*Neighbors) SelectRange ¶
SelectRange select all neighbors from index `start` to `end`. Return an empty set if start or end is out of range.
Click to show internal directories.
Click to hide internal directories.