Skip to main content
. 2023 Sep 7;16(18):6115. doi: 10.3390/ma16186115

Table 3.

Pseudocode of the KNN metamodel developed and investigated in this study.

  PROCEDURE K-NEAREST NEIGHBOURS
  BEGIN
Split dataset into training set and validation set
Define k value
     REPEAT
Calculate the distance between the query point and the training points using the Euclidean distance formula
Add the distance and the index of the training point to an ordered collection of distance subsets
Sort the ordered collection of distance subsets and indices by the distances in ascending order
Pick the top k distance subsets from the sorted collection
Get the labels of the selected k subsets
Include the mean of k labels to the prediction dataset
     UNTIL All queries in the validation dataset are calculated
     RETURN Prediction dataset
  END