0% found this document useful (0 votes)
27 views8 pages

On KNN Algorithm

Uploaded by

MEGHANA BONTHU
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)
27 views8 pages

On KNN Algorithm

Uploaded by

MEGHANA BONTHU
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/ 8

KNN ALGORITHM

kNN (k- Nearest Neighbors):


It can be used for both classification and regression
problems. However, it is more widely used in
classification problems in the industry. K nearest
neighbors is a simple algorithm that stores all available
cases and classifies new cases by a majority vote of its k
neighbors.
These distance functions can be Euclidean,
Manhattan, Minkowski distance.
Steps in KNN algorithm:
Step 1:find the distance
Step 2:find the rank
Step 3:find the nearest neighbor
EXAMPLE : For Given Height And Weight Classify
Whether A Person Is Underweight Or Normal
Height (cm) weight (kg) Class
167 51 Underweight
182 62 Normal
176 69 Normal
173 64 Normal
172 65 Normal
174 56 Underweight
169 58 Normal
173 57 Normal
170 55 Normal
170 57 ?
The distance formula
d=√ (x2-x1)2 +(y2-y1)2
d1=√ (170-167)2 +(57-51)2 =6.7
d2=√ (170-182)2 +(57-62)2 =13
d3=√ (170-176)2 +(57-69)2 =13.4
d4=√ (170-173)2 +(57-64)2 =7.6
d5=√ (170-172)2 +(57-65)2=8.2
d5=√ (170-174)2 +(57-56)2 =4.1
d6=√ (170-169)2 +(57-58)2 =1.4
d7=√ (170-173)2 +(57-57)2 =3
d8=√ (170-170)2 +(57-55)2 =2
Height (cm) weight (kg) Class distance
167 51 Underweight 6.7
182 62 Normal 13
176 69 Normal 13.4
173 64 Normal 7.6
172 65 Normal 8.2
174 56 Underweight 4.1
169 58 Normal 1.4
173 57 Normal 3
170 55 Normal 2
Height (cm) weight (kg) Class distance Rank
167 51 Underweight 6.7 5
182 62 Normal 13 8
176 69 Normal 13.4 9
173 64 Normal 7.6 6
172 65 Normal 8.2 7
174 56 Underweight 4.1 4
169 58 Normal 1.4 1
173 57 Normal 3 3
170 55 Normal 2 2
If k=1 then new case is NORMAL
If k=2 – NORMAL
If k=3 – NORMAL
If k=4 - NORMAL

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy