SlideShare a Scribd company logo
1 of 13
Nearest Neighbor Algorithm Zaffar Ahmed Shaikh
Topics Introduction – Memory-based algorithms K-nearest neighbor (KNN) algorithm How KNN works? KNN Example Different types of KNN
Introduction ,[object Object],[object Object]
How KNN works? Determine K (no of nearest neighbors) Calculate distance (Euclidean, Manhattan) Determine K-minimum distance neighbors Gather category Y values of nearest neighbors  Use simple majority of nearest neighbors to predict value of query instance
KNN Example Predict 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 K Determine value of K  Suppose K = 3 2. Calculate distance Coordinates 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 neighbors K = 3
4. Gather category Y values of nearest neighbors
5. Use simple majority of nearest neighbors to predict value of query instance Here India has won 2 matches 2 (-) signs and Pakistan has won 1 match 1 (+) sign We conclude that India will win today’s match
Different types of KNN  KNN for Classification KNN for Prediction KNN for Smoothing
Thank you
Nearest Neighbor Algorithm  Zaffar Ahmed

More Related Content

What's hot

K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 

What's hot (20)

Unsupervised learning (clustering)
Unsupervised learning (clustering)Unsupervised learning (clustering)
Unsupervised learning (clustering)
 
K - Nearest neighbor ( KNN )
K - Nearest neighbor  ( KNN )K - Nearest neighbor  ( KNN )
K - Nearest neighbor ( KNN )
 
K Nearest Neighbor Algorithm
K Nearest Neighbor AlgorithmK Nearest Neighbor Algorithm
K Nearest Neighbor Algorithm
 
Unsupervised learning clustering
Unsupervised learning clusteringUnsupervised learning clustering
Unsupervised learning clustering
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
 
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
 
Knn 160904075605-converted
Knn 160904075605-convertedKnn 160904075605-converted
Knn 160904075605-converted
 
K mean-clustering
K mean-clusteringK mean-clustering
K mean-clustering
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning Algorithms
 
Random forest
Random forestRandom forest
Random forest
 
Bayes Belief Networks
Bayes Belief NetworksBayes Belief Networks
Bayes Belief Networks
 
K Nearest Neighbors
K Nearest NeighborsK Nearest Neighbors
K Nearest Neighbors
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision tree
 
Machine learning clustering
Machine learning clusteringMachine learning clustering
Machine learning clustering
 
Data mining
Data miningData mining
Data mining
 
Hierarchical Clustering
Hierarchical ClusteringHierarchical Clustering
Hierarchical Clustering
 
K means clustering
K means clusteringK means clustering
K means clustering
 
KNN Algorithm using Python | How KNN Algorithm works | Python Data Science Tr...
KNN Algorithm using Python | How KNN Algorithm works | Python Data Science Tr...KNN Algorithm using Python | How KNN Algorithm works | Python Data Science Tr...
KNN Algorithm using Python | How KNN Algorithm works | Python Data Science Tr...
 
Clustering, k-means clustering
Clustering, k-means clusteringClustering, k-means clustering
Clustering, k-means clustering
 

Similar to Nearest Neighbor Algorithm Zaffar Ahmed

instance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.pptinstance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.ppt
Johny139575
 
Poggi analytics - distance - 1a
Poggi   analytics - distance - 1aPoggi   analytics - distance - 1a
Poggi analytics - distance - 1a
Gaston Liberman
 
TunUp final presentation
TunUp final presentationTunUp final presentation
TunUp final presentation
Gianmario Spacagna
 

Similar to Nearest Neighbor Algorithm Zaffar Ahmed (20)

knn-1.pptx
knn-1.pptxknn-1.pptx
knn-1.pptx
 
K- Nearest Neighbor Approach
K- Nearest Neighbor ApproachK- Nearest Neighbor Approach
K- Nearest Neighbor Approach
 
instance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.pptinstance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.ppt
 
KNN.pptx
KNN.pptxKNN.pptx
KNN.pptx
 
K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)
 
Machine learning in science and industry — day 1
Machine learning in science and industry — day 1Machine learning in science and industry — day 1
Machine learning in science and industry — day 1
 
Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...
Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...
Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...
 
Poggi analytics - distance - 1a
Poggi   analytics - distance - 1aPoggi   analytics - distance - 1a
Poggi analytics - distance - 1a
 
Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)
 
Data analysis of weather forecasting
Data analysis of weather forecastingData analysis of weather forecasting
Data analysis of weather forecasting
 
TunUp final presentation
TunUp final presentationTunUp final presentation
TunUp final presentation
 
K-Means Clustering Simply
K-Means Clustering SimplyK-Means Clustering Simply
K-Means Clustering Simply
 
Knn demonstration
Knn demonstrationKnn demonstration
Knn demonstration
 
MLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic trackMLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic track
 
Ml9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methodsMl9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methods
 
ENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-MeansENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-Means
 
ANLY 501 Lab 7 Presentation Group 8 slide.pptx
ANLY 501 Lab 7 Presentation Group 8 slide.pptxANLY 501 Lab 7 Presentation Group 8 slide.pptx
ANLY 501 Lab 7 Presentation Group 8 slide.pptx
 
Vectorise all the things
Vectorise all the thingsVectorise all the things
Vectorise all the things
 
Classification of Iris Data using Kernel Radial Basis Probabilistic Neural N...
Classification of Iris Data using Kernel Radial Basis Probabilistic  Neural N...Classification of Iris Data using Kernel Radial Basis Probabilistic  Neural N...
Classification of Iris Data using Kernel Radial Basis Probabilistic Neural N...
 
Classification of Iris Data using Kernel Radial Basis Probabilistic Neural Ne...
Classification of Iris Data using Kernel Radial Basis Probabilistic Neural Ne...Classification of Iris Data using Kernel Radial Basis Probabilistic Neural Ne...
Classification of Iris Data using Kernel Radial Basis Probabilistic Neural Ne...
 

More from Zaffar Ahmed Shaikh

Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...
Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...
Identifying Measures to Foster Teachers’ Competence for Personal Learning Env...
Zaffar Ahmed Shaikh
 
Higher Education in Pakistan: An ICT Integration Viewpoint
Higher Education in Pakistan: An ICT Integration ViewpointHigher Education in Pakistan: An ICT Integration Viewpoint
Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
Presentation: Higher Education in Pakistan: An ICT Integration Viewpoint
Presentation: Higher Education in Pakistan: An ICT Integration ViewpointPresentation: Higher Education in Pakistan: An ICT Integration Viewpoint
Presentation: Higher Education in Pakistan: An ICT Integration Viewpoint
Zaffar Ahmed Shaikh
 
Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...
Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...
Presentation: ZPD Incidence Development Strategy for Demand of ICTs in Higher...
Zaffar Ahmed Shaikh
 
Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...
Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...
Usage, Acceptance, Adoption, and Diffusion of Information & Communication Tec...
Zaffar Ahmed Shaikh
 
Chapter 2 Cover Updated By Zaffar Ahmed Shaikh
Chapter 2 Cover Updated By Zaffar Ahmed ShaikhChapter 2 Cover Updated By Zaffar Ahmed Shaikh
Chapter 2 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Chapter 1 Cover Updated By Zaffar Ahmed Shaikh
Chapter 1 Cover Updated By Zaffar Ahmed ShaikhChapter 1 Cover Updated By Zaffar Ahmed Shaikh
Chapter 1 Cover Updated By Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Trust Based Recommendation Systems For Tourism System Zaffar Ahmed Shaikh
Trust Based Recommendation Systems For Tourism System   Zaffar Ahmed ShaikhTrust Based Recommendation Systems For Tourism System   Zaffar Ahmed Shaikh
Trust Based Recommendation Systems For Tourism System Zaffar Ahmed Shaikh
Zaffar Ahmed Shaikh
 
Social Computing Applications Infrastructure
Social Computing Applications InfrastructureSocial Computing Applications Infrastructure
Social Computing Applications Infrastructure
Zaffar Ahmed Shaikh
 
Zaffar+Ahmed+ +Collaborative+Filtering
Zaffar+Ahmed+ +Collaborative+FilteringZaffar+Ahmed+ +Collaborative+Filtering
Zaffar+Ahmed+ +Collaborative+Filtering
Zaffar Ahmed Shaikh
 

More from Zaffar Ahmed Shaikh (17)

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

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Nearest Neighbor Algorithm Zaffar Ahmed

  • 1. Nearest Neighbor Algorithm Zaffar Ahmed Shaikh
  • 2. Topics Introduction – Memory-based algorithms K-nearest neighbor (KNN) algorithm How KNN works? KNN Example Different types of KNN
  • 3.
  • 4. How KNN works? Determine K (no of nearest neighbors) Calculate distance (Euclidean, Manhattan) Determine K-minimum distance neighbors Gather category Y values of nearest neighbors Use simple majority of nearest neighbors to predict value of query instance
  • 5. KNN Example Predict 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 K Determine value of K Suppose K = 3 2. Calculate distance Coordinates 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 neighbors K = 3
  • 9. 4. Gather category Y values of nearest neighbors
  • 10. 5. Use simple majority of nearest neighbors to predict value of query instance Here India has won 2 matches 2 (-) signs and Pakistan has won 1 match 1 (+) sign We conclude that India will win today’s match
  • 11. Different types of KNN KNN for Classification KNN for Prediction KNN for Smoothing