003 01 KNN - Intro W3L1
003 01 KNN - Intro W3L1
K=1
KNN Decision Boundary
Voronoi Tessellation and KNN decision boundaries
K=1
The KNN Algorithm is:
A supervised, non-parametric algorithm
• It does not make any assumptions about the underlying distribution nor tries to
estimate it
• There are no parameters to train like in Logistic/Linear Regression or Bayes
o Parameters allow models to make predictions
• There is a hyperparameter 𝑘, that needs to be tuned
o Hyperparameters help with the learning/prediction process
Used for classification and regression
• Classification: Choose the most frequent class label amongst k-nearest neighbors
• Regression: Take an average over the output values of the k-nearest neighbors and
1
assign to the test point – may be weighted e.g. w = 𝑑 (𝑑: distance from 𝑥)
An Instance-based learning algorithm
• Instead of performing explicit generalization, form hypotheses by comparing new
problem instances with training instances
• (+) Can easily adapt to unseen data
• (-) Complexity of prediction is a function of 𝑛 (size of training data)
A lazy learning algorithm
• Delay computations on training data until a query is made, as opposed to eager
learning
• (+) Good for continuously updated training data like recommender systems
• (-) Slower to evaluate and need to store the whole training data
For more details please visit
http://aghaaliraza.com
Thank you!
8