9.introduction To Artificial Intelligence
9.introduction To Artificial Intelligence
K-nearest Neighbor :
The most basic instance-based method is the k-NEAREST
NEIGHBOR algorithm.
This algorithm assumes all instances correspond to points
in the n-dimensional space(attribute).
• Example: if the goal of the algorithm is to classify the
data with only two attributes (x, y) and each element of
the data is classified into ⬣ or
Then :
• The data will be represented in a 2D space.
• Then the similarity is calculated between the point we want
to classify and all the points in the training set.
• Then the most similar points are selected, and the most
common classification is chosen among the similar points.
Categorical Value
Mother
Training Group Mother Age Fetal Health
2 2 2
Wight
d(xi , xj) = 𝑎 1 − 𝑏1 + 𝑎 2 − 𝑏2 + ⋯ + 𝑎𝑛 − 𝑏𝑛
25 67.6 Healthy
33 88.9 Healthy
d(x1 , xq) = 25 − 23 2 + 67.6 − 60 2 =7.85
48 90 Not Healthy
d(x2 , xq) = 33 − 23 2 + 88.9 − 60 2 =30.58
60 50 Not Healthy