Sabtu, 05 Agustus 2023

Calculation of K-Nearest Neighbor With Euclidean Distance

In this post, I will discuss the calculation of K-Nearest Neighbor with Euclidean Distance.

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

The data we will use is:
  • Consists of 10 data
  • Consists of 2 criteria
  • K = 5



Information :
  • Which will be categorized consists of Non-Academic values ​​and Academic values.
  • Status consists of TMS (Not Qualified) and MS (Qualified).
  • What we will classify is Name = See, Non-Academic Value = 81 and Academic Value = 86, Status = ?

Calculation (formula to be used) :


  • 79 is Alan's Non-Academic score
  • 81 is See's Non-Academic score
  • 97 is Alan's Academic score
  • 86 is See's 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 Cee and Moon's result is 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 Eks are eligible, while Cee, Moon and Tet are ineligible (2 met the requirements and 3 did not fulfill 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