Skip to main content
. 2022 May 3;12(5):1134. doi: 10.3390/diagnostics12051134
Algorithm 1 KNN Algorithm to Differentiate Benign or Malignant Tumor
  • 1:

    Identification: Disease

  • 2:

    Dataset: WBCD from Kaggle

  • 3:

    Build the training normal dataset D; D ← Dataset (699 entries)

  • 4:

    Input: Data ← Text

  • 5:

    Output: Normal cells, Benign or Malignant

  • 6:

    for each instance X in the test data do

  • 7:

       if X has an unknown system call then

  • 8:

         X is abnormal

  • 9:

       else

  • 10:

         for each instance D_j   in   training   data do

  • 11:

            calculate sim(X, D_j)

  • 12:

            if sim(X, D_j)   equals   to   1.0 then

  • 13:

              X is normal; exist

  • 14:

              Find k biggest scores of sim(X,D)

  • 15:

              calculate sim-avg for k-nearest neighbors

  • 16:

            end if

  • 17:

         end for

  • 18:

       end if

  • 19:

    end for

  • 20:

    if sim-avg is greater than threshold then

  • 21:

       X is normal

  • 22:

    else

  • 23:

       X is abnormal

  • 24:

    end if