Minggu, 20 Agustus 2023

Calculation of K-Nearest Neighbor with Manhattan Distance (5 Criteria)

In this post, I will discuss the calculation of K-Nearest Neighbor with Manhattan Distance using 5 criteria.

The classification that will be discussed is the Classification of Scholarship Recipients.

The data we will use is :

  • Consists of 10 data
  • Consists of 5 criteria
  • K = 5



Information :

  • What will be categorized consists of Mathematics scores, Indonesian B scores, English B grades, Science scores and Non-Academic scores.
  • Status consists of Not Qualified and Qualified.
  • What we will classify is Name = See, Mathematics Score = 81, Indonesian Score = 86, English Score = 79, Science Score = 93 and Non Academic Score = 87, Status = ?

 Calculation (formula to be used):



  • 79 is Alan's Math score
  • 81 is See's Math score
  • 88 is Alan's Indonesian score
  • 86 is See's Indonesian score
  • 72 is Alan's British value
  • 79 is See's British value
  • 92 is Alan's Science score
  • 93 is See's Science score
  • 97 is Alan's Non-Academic score
  • 87 is See's Non-Academic score
  • Then do the same calculations on data belonging to Dani, Rey and so on.

 Then the calculation will be obtained as follows :



After that, do the ranking from the smallest to the largest value, the results obtained are as follows :



After getting the ranking, we can ensure that on behalf of See is eligible to receive a Scholarship or Not Eligible to receive a Scholarship.



Explanation :

  • If using K=1 then the result is eligible because Dani the result is eligible.
  • If using K=3 then the result is not eligible because Dani's result is eligible, while Alan and Cee's results are not eligible (fulfilling the requirements is 1 and not fulfilling the requirements is 2).
  • If using K=5, the result is not eligible because Dani and Rey are eligible, while Alan, Cee and Eks are not eligible (2 meet the requirements and 3 do not meet the requirements).

So the final result See does not meet the requirements.



Notes :

  • The value of K is independent (try to have an odd number so it doesn't confuse us when there are the same number of voting results).

Tidak ada komentar:

Posting Komentar