SlideShare a Scribd company logo
1
KOTA BARU PARAHYANGAN BANDUNG
Machine Learning
k-Nearest Neighbour
2
k-NN
3
References
• KTH Royal Institute – Lecture Notes
• K-Nearest Neighbor Learning - Dipanjan
Chakraborty
• T. Mitchell, Machine Learning,
McGraw-Hill (Recommended)
• Papers, Website, tutorial
• The k-NN algorithm is among the simplest of all
machine learning algorithms
• Supervised learning
• Data are represented in a vector space
• Most basic instance-based method
– Disadvantage of instance-based methods is that the
costs of classifying new instances can be high
– Nearly all computation takes place at classification
time rather than learning time
k-NN Overview
• KNN is a non-parametric, lazy learning algorithm
– Non-parametric: it does not make any assumptions on the
underlying data distribution. in the “real world”, most of the
data does not obey the typical theoretical assumptions
made (as in linear regression models, for example)
– Lazy: it does not use the training data points to do any
generalization. In other words, there is no explicit training
phase or it is very minimal.In contrast to so called “eager
learning” algorithms (which carries out learning without knowing
the test example, and after learning training examples can be
discarded)
• Its purpose is to use a database in which the data points
are separated into several classes to predict the
classification of a new sample point
• KNN can be used for classification
k-NN Overview
• Learning = storing all training instances
• Classification = assigning target function
to a new instance
• Referred to as “Lazy” learning
K-NN Overview
• Credit ratings — collecting financial
characteristics vs. comparing people with
similar financial features to a database
• In political science — classing a potential
voter to a “will vote” or “will not vote”, or to
“vote Democrat” or “vote Republican”.
• Handwriting detection (like OCR), image
recognition and even video recognition.
k-NN Application
k-NN Architecture
k-NN Algorithm
• Given a new set of measurements,
perform the following test:
– Find (using Euclidean distance, for example),
the k nearest entities from the training set.
These entities have known labels. The choice
of k is left to us.
– Among these k entities, which label is most
common? That is the label for the unknown
entity.
k-NN Algorithm
• Distance Metric
• k-Nearest Neighbor Predictions
• Distance Weighting
Training machine learning knn 2017
Training machine learning knn 2017
Training machine learning knn 2017
k-NN Algorithm – Example
• For each training example <x,f(x)>, add
the example to the list of
training_example
• Given a query instance xq to be classified,
– Let x1, x2, ... xk denote the k instances from
training_examples that are nearest to xq
– Return the class that represents the maximum
of the k instances
• If K = 5, then in this case query instance xq will be
classified as negative since three of its nearest
neighbors are classified as negative
k-NN Summary
• Advantages
– Learning is extremely simple and intuitive
– Very flexible decision boundaries
– Variable-sized hypothesis space
• Disadvantages
– distance function must be carefully chosen or tuned
– irrelevant or correlated features have high impact and
must be eliminated
– typically cannot handle high dimensionality
computational
– computational costs: memory and classification-time
computation
When to Consider Nearest
Neighbor ?
• Lots of training data and no training stage, all the work is
done during the test stage
• Advantages:
– Can be applied to the data from any distribution
• for example, data does not have to be separable with a linear
boundary
– Training is very fast
– Learn complex target functions
– Don’t lose information
• Disadvantages:
– Choosing k may be tricky
– Slow at query time
– Easily fooled by irrelevant attributes
– Need large number of samples for accuracy

More Related Content

PPTX
Support Vector Machine ppt presentation
PPTX
Multilayer Perceptron Neural Network MLP
PPTX
Decision Trees for Classification: A Machine Learning Algorithm
PPTX
AI-03 Problems State Space.pptx
PPT
Decision tree and random forest
PDF
PCA (Principal component analysis)
PPTX
Dbscan algorithom
PPTX
Exploratory Data Analysis (EDA) .pptx
Support Vector Machine ppt presentation
Multilayer Perceptron Neural Network MLP
Decision Trees for Classification: A Machine Learning Algorithm
AI-03 Problems State Space.pptx
Decision tree and random forest
PCA (Principal component analysis)
Dbscan algorithom
Exploratory Data Analysis (EDA) .pptx

What's hot (20)

PPTX
Lect4 principal component analysis-I
PPT
Opinion Mining Tutorial (Sentiment Analysis)
PPTX
NLP.pptx
PPTX
Introduction to Data Analytics
PPTX
Decision tree
PPTX
DATA WRANGLING presentation.pptx
PPTX
CART – Classification & Regression Trees
PPTX
Causal inference in practice
PPTX
Support vector machine
PPTX
Classification and Regression
PPTX
Transformation of variables
PPTX
Random Forest
PPTX
Decision Trees
PPTX
Decision tree
PDF
Decision trees in Machine Learning
PPTX
Support vector machine
PDF
Deep Learning for Graphs
PPT
Support Vector machine
PDF
Bias and variance trade off
PPT
Simple linear regression (final)
Lect4 principal component analysis-I
Opinion Mining Tutorial (Sentiment Analysis)
NLP.pptx
Introduction to Data Analytics
Decision tree
DATA WRANGLING presentation.pptx
CART – Classification & Regression Trees
Causal inference in practice
Support vector machine
Classification and Regression
Transformation of variables
Random Forest
Decision Trees
Decision tree
Decision trees in Machine Learning
Support vector machine
Deep Learning for Graphs
Support Vector machine
Bias and variance trade off
Simple linear regression (final)
Ad

Similar to Training machine learning knn 2017 (20)

PPTX
KNN.pptx
PDF
Natural Language Processing of applications.pdf
PPTX
K Nearest Neighbor Algorithm
PDF
tghteh ddh4eth rtnrtrgthgh12500123196.pdf
PPTX
K-Nearest Neighbor(KNN)
PDF
Unit 1 KNN.pptx one of the important chapters
PPTX
k-Nearest Neighbors with brief explanation.pptx
PDF
Supervised Machine Learning PPT by K. Adisesha
PPTX
KNN Classificationwithexplanation and examples.pptx
PPTX
Nearest neighbour algorithm
PPTX
KNN and steps to define knn and various properties.pptx
PPT
Supervised Learningclassification Part1.ppt
PPTX
K Nearest Neighbour (KNN) Alg.pptx fro machine learning
PPTX
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
PPTX
artificial intelligence.pptx
PDF
Lecture03 - K-Nearest-Neighbor Machine learning
PPTX
K neareast neighbor algorithm presentation
PDF
Knn algorithym execution - lab 9 ppt.pdf
PDF
Lecture 6 - Classification Classification
KNN.pptx
Natural Language Processing of applications.pdf
K Nearest Neighbor Algorithm
tghteh ddh4eth rtnrtrgthgh12500123196.pdf
K-Nearest Neighbor(KNN)
Unit 1 KNN.pptx one of the important chapters
k-Nearest Neighbors with brief explanation.pptx
Supervised Machine Learning PPT by K. Adisesha
KNN Classificationwithexplanation and examples.pptx
Nearest neighbour algorithm
KNN and steps to define knn and various properties.pptx
Supervised Learningclassification Part1.ppt
K Nearest Neighbour (KNN) Alg.pptx fro machine learning
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
artificial intelligence.pptx
Lecture03 - K-Nearest-Neighbor Machine learning
K neareast neighbor algorithm presentation
Knn algorithym execution - lab 9 ppt.pdf
Lecture 6 - Classification Classification
Ad

Recently uploaded (20)

PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
Cost to Outsource Software Development in 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
Computer Software and OS of computer science of grade 11.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
AutoCAD Professional Crack 2025 With License Key
wealthsignaloriginal-com-DS-text-... (1).pdf
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Patient Appointment Booking in Odoo with online payment
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
Cost to Outsource Software Development in 2025
Complete Guide to Website Development in Malaysia for SMEs
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 41
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Reimagine Home Health with the Power of Agentic AI​
Navsoft: AI-Powered Business Solutions & Custom Software Development
Designing Intelligence for the Shop Floor.pdf
Digital Systems & Binary Numbers (comprehensive )

Training machine learning knn 2017

  • 1. 1 KOTA BARU PARAHYANGAN BANDUNG Machine Learning k-Nearest Neighbour
  • 3. 3 References • KTH Royal Institute – Lecture Notes • K-Nearest Neighbor Learning - Dipanjan Chakraborty • T. Mitchell, Machine Learning, McGraw-Hill (Recommended) • Papers, Website, tutorial
  • 4. • The k-NN algorithm is among the simplest of all machine learning algorithms • Supervised learning • Data are represented in a vector space • Most basic instance-based method – Disadvantage of instance-based methods is that the costs of classifying new instances can be high – Nearly all computation takes place at classification time rather than learning time k-NN Overview
  • 5. • KNN is a non-parametric, lazy learning algorithm – Non-parametric: it does not make any assumptions on the underlying data distribution. in the “real world”, most of the data does not obey the typical theoretical assumptions made (as in linear regression models, for example) – Lazy: it does not use the training data points to do any generalization. In other words, there is no explicit training phase or it is very minimal.In contrast to so called “eager learning” algorithms (which carries out learning without knowing the test example, and after learning training examples can be discarded) • Its purpose is to use a database in which the data points are separated into several classes to predict the classification of a new sample point • KNN can be used for classification k-NN Overview
  • 6. • Learning = storing all training instances • Classification = assigning target function to a new instance • Referred to as “Lazy” learning K-NN Overview
  • 7. • Credit ratings — collecting financial characteristics vs. comparing people with similar financial features to a database • In political science — classing a potential voter to a “will vote” or “will not vote”, or to “vote Democrat” or “vote Republican”. • Handwriting detection (like OCR), image recognition and even video recognition. k-NN Application
  • 9. k-NN Algorithm • Given a new set of measurements, perform the following test: – Find (using Euclidean distance, for example), the k nearest entities from the training set. These entities have known labels. The choice of k is left to us. – Among these k entities, which label is most common? That is the label for the unknown entity.
  • 10. k-NN Algorithm • Distance Metric • k-Nearest Neighbor Predictions • Distance Weighting
  • 14. k-NN Algorithm – Example • For each training example <x,f(x)>, add the example to the list of training_example • Given a query instance xq to be classified, – Let x1, x2, ... xk denote the k instances from training_examples that are nearest to xq – Return the class that represents the maximum of the k instances
  • 15. • If K = 5, then in this case query instance xq will be classified as negative since three of its nearest neighbors are classified as negative
  • 16. k-NN Summary • Advantages – Learning is extremely simple and intuitive – Very flexible decision boundaries – Variable-sized hypothesis space • Disadvantages – distance function must be carefully chosen or tuned – irrelevant or correlated features have high impact and must be eliminated – typically cannot handle high dimensionality computational – computational costs: memory and classification-time computation
  • 17. When to Consider Nearest Neighbor ? • Lots of training data and no training stage, all the work is done during the test stage • Advantages: – Can be applied to the data from any distribution • for example, data does not have to be separable with a linear boundary – Training is very fast – Learn complex target functions – Don’t lose information • Disadvantages: – Choosing k may be tricky – Slow at query time – Easily fooled by irrelevant attributes – Need large number of samples for accuracy