Skip to main content
. 2022 Nov 27;22(23):9233. doi: 10.3390/s22239233
Algorithm 4: The K-NN Algorithm
  1: Classify (X,Y,x).
  2: for i=1 to n do
  3:          Calculate the Euclidean distance dE(Xi,x).
  4: end.
  5: Compute set I having the indices for the k smallest distances dE(Xi,x).
  6: Return majority label for Yi where iI.