yat  0.21pre
Neighbor Weighting Method

Description

Neighbor Weighting Method is a concept used in connection with theplu::yat::classifier::KNN - classes used as the template argument NeighborWeighting should implement this concept.

Requirements

Classes modelling the concept Neighbor Weighting Method should be DefaultConstructible and Assignable as well as implement the following public function:

void operator()(const utility::VectorBase& distance,
                const std::vector<size_t>& k_sorted,
                const Target& target,
                utility::VectorMutable& prediction) const

For a test sample, this function should calculate a total vote (i.e. based on all k nearest neighbors) for each class. The vector distance contains the distances from a test sample to all training samples. The vector k_sorted contains the indices (for both distance and target) to the k training samples with the smallest distances to the test sample. The class for each training sample is given by target, which is sorted in the same sample order as distance. For each class the function calculates a total vote based on the the nearest neighbors of the test sample that belong to the class. The total vote for each class is stored in the vector prediction. The function should be implemented such that nearest neighbors with distance infinity do not vote.

Implementations

Examples of classes modelling the concept Neighbor Weighting Method include theplu::yat::classifier::KNN_Uniform, theplu::yat::classifier::KNN_ReciprocalDistance and theplu::yat::classifier::KNN_ReciprocalRank.


Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14