0% found this document useful (0 votes)
39 views13 pages

KNN Ques

machine learning KNN Ques

Uploaded by

webdev397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views13 pages

KNN Ques

machine learning KNN Ques

Uploaded by

webdev397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

knn

Practice problems
Q1
Q1
• let's assume the value of K is 5.
• Here's the new data entry:
Sol 1
• To know its class, we have to calculate the distance from
the new entry to other entries in the data set using the
Euclidean distance formula.
• Here's the formula: √(X₂-X₁)²+(Y₂-Y₁)²
• Where:
X₂ = New entry's brightness (20).
X₁= Existing entry's brightness.
Y₂ = New entry's saturation (35).
Y₁ = Existing entry's saturation.
• Distance #1
• For the first row, d1:

d1 = √(20 - 40)² + (35 - 20)²


= √400 + 225
= √625
= 25
• Distance #2
• For the second row, d2:

d2 = √(20 - 50)² + (35 - 50)²


= √900 + 225
= √1125
= 33.54
Let's rearrange the distances in ascending
order:
Since we chose 5 as the value of K, we'll
only consider the first five rows. That is:
As you can see above, the majority class within the 5
nearest neighbors to the new entry is Red. Therefore,
we'll classify the new entry as Red.
Here's the updated table:
Q2

Take k=3

You might also like