SlideShare a Scribd company logo
Nearest Neighbor AlgorithmZaffar Ahmed Shaikh
TopicsIntroduction – Memory-based algorithmsK-nearest neighbor (KNN) algorithmHow KNN works?KNN ExampleDifferent types of KNN
IntroductionMemory-based algorithms utilize the entire user-item database to generate a prediction. They find a set of users, known as neighbors, that have a history of agreeing with the target user. Once a neighborhood of users is formed, the preferences of neighbors are combined to produce a prediction or top-K recommendation for the active user.   K-nearest neighbor (KNN)The nearest neighbor algorithm measures the distance dE(Xi,Xj)between query points Xi and a set of training samples Xjto classify a new object based on majority of K-nearest neighbor category of Y attributes of training samples. Query point Xi = x1, x2, x3, ……….., xnTraining Sample Xj= x1, x2, x3, ……….., xn
How KNN works?Determine K (no of nearest neighbors)Calculate distance (Euclidean, Manhattan)Determine K-minimum distance neighborsGather category Y values of nearest neighbors Use simple majority of nearest neighbors to predict value of query instance
KNN ExamplePredict who will win today’s Cricket match between India and Pakistan based on users rating and previous results of matches played between the two teams.
1. Determine KDetermine value of K Suppose K = 32. Calculate distanceCoordinates of query instance are (4,3,3)Coordinates of training instance(1) are (7,2,1)D = SQRT ((7-4)2+(2-3) 2+(1-3) 2) = 3.74165
2. Calculate distance
3. Determine K-minimum distance neighborsK = 3
4. Gather category Y values of nearest neighbors
5. Use simple majority of nearest neighbors to predict value of query instanceHere India has won 2 matches 2 (-) signs and Pakistan has won 1 match 1 (+) signWe conclude that India will win today’s match
Different types of KNN KNN for ClassificationKNN for PredictionKNN for Smoothing
Thank you
Nearest Neighbor Algorithm  Zaffar Ahmed

More Related Content

What's hot (20)

PPTX
Random forest
Ujjawal
 
PPTX
K-Nearest Neighbor(KNN)
Abdullah al Mamun
 
PPTX
Unit 2 unsupervised learning.pptx
Dr.Shweta
 
PDF
Sequential Pattern Mining and GSP
Hamidreza Mahdavipanah
 
PPTX
K-Nearest Neighbor Classifier
Neha Kulkarni
 
PDF
Dimensionality Reduction
Saad Elbeleidy
 
PPTX
Apriori algorithm
Mainul Hassan
 
PPTX
Decision Tree Learning
Md. Ariful Hoque
 
PPTX
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Simplilearn
 
PPTX
Support vector machine
zekeLabs Technologies
 
PPTX
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Simplilearn
 
PPTX
Classification and Regression
Megha Sharma
 
ODP
Machine Learning with Decision trees
Knoldus Inc.
 
PPTX
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
PPTX
Association rule mining.pptx
maha797959
 
PPTX
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Edureka!
 
PPTX
Random forest algorithm
Rashid Ansari
 
PPTX
Dimension reduction techniques[Feature Selection]
AAKANKSHA JAIN
 
Random forest
Ujjawal
 
K-Nearest Neighbor(KNN)
Abdullah al Mamun
 
Unit 2 unsupervised learning.pptx
Dr.Shweta
 
Sequential Pattern Mining and GSP
Hamidreza Mahdavipanah
 
K-Nearest Neighbor Classifier
Neha Kulkarni
 
Dimensionality Reduction
Saad Elbeleidy
 
Apriori algorithm
Mainul Hassan
 
Decision Tree Learning
Md. Ariful Hoque
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Simplilearn
 
Support vector machine
zekeLabs Technologies
 
Random Forest Algorithm - Random Forest Explained | Random Forest In Machine ...
Simplilearn
 
Classification and Regression
Megha Sharma
 
Machine Learning with Decision trees
Knoldus Inc.
 
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Association rule mining.pptx
maha797959
 
Decision Tree Algorithm & Analysis | Machine Learning Algorithm | Data Scienc...
Edureka!
 
Random forest algorithm
Rashid Ansari
 
Dimension reduction techniques[Feature Selection]
AAKANKSHA JAIN
 

Similar to Nearest Neighbor Algorithm Zaffar Ahmed (20)

PPTX
knn-1.pptx
MohammedSahil63
 
PPTX
Statistical Machine Learning unit3 lecture notes
SureshK256753
 
PDF
Natural Language Processing of applications.pdf
pranavi452104
 
PPTX
K- Nearest Neighbor Approach
Kumud Arora
 
PPTX
k-nearest neighbour Machine Learning.pptx
SabbirAhmed346057
 
PPTX
k-Nearest Neighbors with brief explanation.pptx
gamingzonedead880
 
PDF
k-nearest neighbour Machine Learning.pdf
SabbirAhmed346057
 
PPTX
KNN Classificationwithexplanation and examples.pptx
ansarinazish958
 
PDF
Understanding K-Nearest Neighbor (KNN) Algorithm
Faculty of Computers and Informatics, Suez Canal University, Ismailia, Egypt
 
PDF
Lecture 6 - Classification Classification
viyah59114
 
PDF
tghteh ddh4eth rtnrtrgthgh12500123196.pdf
NidhiKumari899659
 
PDF
Machine Learning-Lec7 Bayesian calssification.pdf
BeshoyArnest
 
PPTX
MachineLearning.pptx
Bangtangurl
 
PDF
Knn algorithym execution - lab 9 ppt.pdf
rajalakshmir71
 
PPTX
KNN CLASSIFIER, INTRODUCTION TO K-NEAREST NEIGHBOR ALGORITHM.pptx
Nishant83346
 
PPTX
K- Nearest Neighbour Algorithm.pptx
DivyaKS12
 
PPTX
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
BootNeck1
 
knn-1.pptx
MohammedSahil63
 
Statistical Machine Learning unit3 lecture notes
SureshK256753
 
Natural Language Processing of applications.pdf
pranavi452104
 
K- Nearest Neighbor Approach
Kumud Arora
 
k-nearest neighbour Machine Learning.pptx
SabbirAhmed346057
 
k-Nearest Neighbors with brief explanation.pptx
gamingzonedead880
 
k-nearest neighbour Machine Learning.pdf
SabbirAhmed346057
 
KNN Classificationwithexplanation and examples.pptx
ansarinazish958
 
Lecture 6 - Classification Classification
viyah59114
 
tghteh ddh4eth rtnrtrgthgh12500123196.pdf
NidhiKumari899659
 
Machine Learning-Lec7 Bayesian calssification.pdf
BeshoyArnest
 
MachineLearning.pptx
Bangtangurl
 
Knn algorithym execution - lab 9 ppt.pdf
rajalakshmir71
 
KNN CLASSIFIER, INTRODUCTION TO K-NEAREST NEIGHBOR ALGORITHM.pptx
Nishant83346
 
K- Nearest Neighbour Algorithm.pptx
DivyaKS12
 
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
BootNeck1
 
Ad

More from Zaffar Ahmed Shaikh (17)

PPTX
SkillsRec: A Novel Semantic Analysis Driven Learner Skills Mining and Filteri...
Zaffar Ahmed Shaikh
 
PDF
Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...
Zaffar Ahmed Shaikh
 
PDF
Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
PPTX
Presentation: Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
PPT
Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...
Zaffar Ahmed Shaikh
 
PDF
Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...
Zaffar Ahmed Shaikh
 
PDF
Role of ICT in Shaping the Future of Pakistani Higher Education System
Zaffar Ahmed Shaikh
 
PDF
Role of Teacher in Personal Learning Environments
Zaffar Ahmed Shaikh
 
PPTX
Presentation - Role of Teacher in Personal Learning Environments
Zaffar Ahmed Shaikh
 
DOC
Network Theory
Zaffar Ahmed Shaikh
 
DOC
Introduction to Social Computing - Book Chapter
Zaffar Ahmed Shaikh
 
DOC
Chapter 2 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
DOC
Chapter 1 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
PPTX
Prediction Markets
Zaffar Ahmed Shaikh
 
DOCX
Trust Based Recommendation Systems For Tourism System Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
PPTX
Social Computing Applications Infrastructure
Zaffar Ahmed Shaikh
 
PPSX
Zaffar+Ahmed+ +Collaborative+Filtering
Zaffar Ahmed Shaikh
 
SkillsRec: A Novel Semantic Analysis Driven Learner Skills Mining and Filteri...
Zaffar Ahmed Shaikh
 
Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...
Zaffar Ahmed Shaikh
 
Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
Presentation: Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...
Zaffar Ahmed Shaikh
 
Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...
Zaffar Ahmed Shaikh
 
Role of ICT in Shaping the Future of Pakistani Higher Education System
Zaffar Ahmed Shaikh
 
Role of Teacher in Personal Learning Environments
Zaffar Ahmed Shaikh
 
Presentation - Role of Teacher in Personal Learning Environments
Zaffar Ahmed Shaikh
 
Network Theory
Zaffar Ahmed Shaikh
 
Introduction to Social Computing - Book Chapter
Zaffar Ahmed Shaikh
 
Chapter 2 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Chapter 1 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Prediction Markets
Zaffar Ahmed Shaikh
 
Trust Based Recommendation Systems For Tourism System Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Social Computing Applications Infrastructure
Zaffar Ahmed Shaikh
 
Zaffar+Ahmed+ +Collaborative+Filtering
Zaffar Ahmed Shaikh
 
Ad

Recently uploaded (20)

PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 

Nearest Neighbor Algorithm Zaffar Ahmed

  • 2. TopicsIntroduction – Memory-based algorithmsK-nearest neighbor (KNN) algorithmHow KNN works?KNN ExampleDifferent types of KNN
  • 3. IntroductionMemory-based algorithms utilize the entire user-item database to generate a prediction. They find a set of users, known as neighbors, that have a history of agreeing with the target user. Once a neighborhood of users is formed, the preferences of neighbors are combined to produce a prediction or top-K recommendation for the active user. K-nearest neighbor (KNN)The nearest neighbor algorithm measures the distance dE(Xi,Xj)between query points Xi and a set of training samples Xjto classify a new object based on majority of K-nearest neighbor category of Y attributes of training samples. Query point Xi = x1, x2, x3, ……….., xnTraining Sample Xj= x1, x2, x3, ……….., xn
  • 4. How KNN works?Determine K (no of nearest neighbors)Calculate distance (Euclidean, Manhattan)Determine K-minimum distance neighborsGather category Y values of nearest neighbors Use simple majority of nearest neighbors to predict value of query instance
  • 5. KNN ExamplePredict who will win today’s Cricket match between India and Pakistan based on users rating and previous results of matches played between the two teams.
  • 6. 1. Determine KDetermine value of K Suppose K = 32. Calculate distanceCoordinates of query instance are (4,3,3)Coordinates of training instance(1) are (7,2,1)D = SQRT ((7-4)2+(2-3) 2+(1-3) 2) = 3.74165
  • 8. 3. Determine K-minimum distance neighborsK = 3
  • 9. 4. Gather category Y values of nearest neighbors
  • 10. 5. Use simple majority of nearest neighbors to predict value of query instanceHere India has won 2 matches 2 (-) signs and Pakistan has won 1 match 1 (+) signWe conclude that India will win today’s match
  • 11. Different types of KNN KNN for ClassificationKNN for PredictionKNN for Smoothing