CSC411/2515 Lecture 2: Nearest Neighbors
Roger Grosse, Amir-massoud Farahmand, and Juan Carrasquilla
University of Toronto
UofT CSC411-Lec2 1 / 26
CSC411/2515 Lecture 2: Nearest Neighbors Roger Grosse, Amir-massoud - - PowerPoint PPT Presentation
CSC411/2515 Lecture 2: Nearest Neighbors Roger Grosse, Amir-massoud Farahmand, and Juan Carrasquilla University of Toronto UofT CSC411-Lec2 1 / 26 Introduction Today (and for the next 5 weeks) were focused on supervised learning. This
UofT CSC411-Lec2 1 / 26
UofT CSC411-Lec2 2 / 26
UofT CSC411-Lec2 3 / 26
◮ Representation = mapping to another space that’s easy to manipulate ◮ Vectors are a great representation since we can do linear algebra! UofT CSC411-Lec2 4 / 26
UofT CSC411-Lec2 5 / 26
◮ Regression: t is a real number (e.g. stock price) ◮ Classification: t is an element of a discrete set {1, . . . , C} ◮ These days, t is often a highly structured object (e.g. image)
◮ Note: these superscripts have nothing to do with exponentiation! UofT CSC411-Lec2 6 / 26
j
j
x(i)∈train. set
UofT CSC411-Lec2 7 / 26
UofT CSC411-Lec2 8 / 26
UofT CSC411-Lec2 9 / 26
UofT CSC411-Lec2 10 / 26
[Pic by Olga Veksler]
Nearest neighbors sensitive to noise or mis-labeled data (“class noise”). Solution? Smooth by having k nearest neighbors vote Algorithm (kNN):
y = arg max
t(z) k
δ(t(z), t(r)) UofT CSC411-Lec2 11 / 26
UofT CSC411-Lec2 12 / 26
UofT CSC411-Lec2 13 / 26
◮ Good at capturing fine-grained patterns ◮ May overfit, i.e. be sensitive to random idiosyncrasies in the training
◮ Makes stable predictions by averaging over lots of examples ◮ May underfit, i.e. fail to capture important regularities
UofT CSC411-Lec2 14 / 26
UofT CSC411-Lec2 15 / 26
UofT CSC411-Lec2 16 / 26
ǫ)d
UofT CSC411-Lec2 17 / 26
UofT CSC411-Lec2 18 / 26
UofT CSC411-Lec2 19 / 26
◮ Calculuate D-dimensional Euclidean distances with N data points:
◮ Sort the distances: O(N log N)
UofT CSC411-Lec2 20 / 26
UofT CSC411-Lec2 21 / 26
◮ Distance measure: average distance between corresponding points on
UofT CSC411-Lec2 22 / 26
UofT CSC411-Lec2 23 / 26
UofT CSC411-Lec2 24 / 26
UofT CSC411-Lec2 25 / 26
UofT CSC411-Lec2 26 / 26