Rabu, 02 Agustus 2023

Calculation of K-Nearest Neighbor With Manhattan Distance

 In this post, I will discuss the calculation of K-Nearest Neighbor with Manhattan 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.
  • Keep in mind, for Manhattan the final result must be absolute value.

 


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 MS because Dani the result is MS.
  • If using K=3, the result is TMS because Dani's result is MS, while Cee and Moon's result is TMS (1 MS and 2 TMS).
  • If using K=5 then the result is TMS because Dani's result is MS, while Cee, Moon, Jo and Alan the result is TMS (1 MS and 4 TMS).

So that the final result See TMS



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