kncount: Counting the number of each class in K nearest neighbor
Description
The function to count how many neighbor of each instance belong to each class.
Usage
kncount(knidex, classArray)
Value
The matrix with the number of columns equal to the number of classes. Each a[i][j] represents the number of K-nearest neighbors of i th instance belonging to the class j th
Arguments
knidex
The matrix of K nearest neighbor of dataset
classArray
The index of last instance of the first class in the dataset or the vector containing indices of last instances of each class.
Author
Wacharasak Siriseriwan <wacharasak.s@gmail.com>
Details
The dataset is expected to be sorted as all m1 instances in the first class are in the first m1 instances of the dataset following with all m2 instances in the next m2 instances etc. before performing k-nearest neighbor with the knearest function.