Skip to main content
. 2022 Sep 14;22(18):6955. doi: 10.3390/s22186955
Algorithm 2 Pseudo code for K-nearest neighbors training
Require: Initialize k,func,target,datat
Require: Initialize neighbors=[]
 Train first weak decision tree model
for Each observation datat do
  distance = euclidean distance (data[:1],target)
  calculate euclidean distance
  append neighbors
end for
 pick the top-K closest training data
 take the most common label of these labels
return labels