5c. Nearest Neighbour Classifier
5c. Nearest Neighbour Classifier
Nearest-Neighbor Classifier training data (or only minor processing) and waits until it is given
a test tuple
• Decision boundaries: Voronoi diagram visualization, show how input space divided
into classes;
(Instance Based Learning) Eager learning : Given a set of training tuples, constructs a
classification model before receiving new (e.g., test) data to
• Each line segment is equidistant between two points of opposite classes
Atr1 ……... AtrN Class • Use training records to • Similar inputs map to similar outputs
predict the class label of
A unseen cases – If not true => learning is impossible
B – If true => learning reduces to defining “similar”
B
Unseen Case
C
Atr1 AtrN
• Not all similarities created equal
A ……...
C
– predicting a person’s weight may depend on different attributes
than predicting their IQ
B
Nearest Neighbors
Nearest Neighbor Classifiers Definition of Nearest Neighbor [Pic by Olga Veksler]
• Basic idea:
– If it walks like a duck, quacks like a duck, then it’s probably a duck
Compute X X X
Distance Test
Record
13 / 22
𝑞 1/𝑞
𝑖 𝑖 𝑖
5. end for