








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









Greg Hamerly
Some content from Tom Mitchell.
Outline
1 k-Nearest Neighbor
k-Nearest Neighbor
Why not use more than just one neighbor?
k-Nearest neighbor: Given xq , take vote among its k nearest neighbors (if discrete-valued target function) Let N(xq , k) be the indexes of the k nearest neighbors of xq Use the nearest neighbors to predict xq
k-Nearest Neighbor
Regression: mean of f values over k nearest neighbors: ˆf (xq ) ← 1 k
i∈N(xq ,k)
f (xi )
-0.
0
1
0 0.2 0.4 0.6 0.8 1
k-Nearest Neighbor
ˆf (xq ) ← k^ −^1 nV (k, xq , d) n is the number of examples in the dataset, and V is the volume of the smallest d-sphere centered at xq that covers the k neighbors
0
5
10
-15 -10 -5 (^0 5 10) 7 / 14
k-Nearest Neighbor
How do we compare two points for similarity? → Similarity ∝ 1 /distance Common distance metrics for vectors a and b: Euclidean: d(a, b) =
i
(ai − bi )^2
Manhattan (aka city-block): d(a, b) =
i
|ai − bi |
General (Minkowski) p-norm:
dp (a, b) =
i
|ai − bi |p
) 1 /p
k-Nearest Neighbor
Consider p(x) defines probability that instance x will be labeled 1 (positive) versus 0 (negative).
Nearest neighbor: As n → ∞, approaches Gibbs Algorithm Gibbs: with probability p(x) predict 1, else 0
k-Nearest neighbor: As n → ∞ and k gets large, approaches Bayes optimal Bayes optimal: if p(x) > .5 then predict 1, else 0
Recall Gibbs has at most twice the expected error of Bayes optimal
k-Nearest Neighbor
What is the inductive bias of k-NN?
What is the statistical bias and statistical variance of k-NN? In particular, how do they vary with k? Think about extreme k values, e.g. k = 1 or k = n.
k-Nearest Neighbor
Imagine instances described by 20 attributes, but only 2 are relevant to target function
Nearest neighbor is easily misled when high-dimensional X (a symptom of the ‘curse of dimensionality’)
Why?
Can we fix this problem?
k-Nearest Neighbor
When not all attributes are equally relevant, we can give them different weights – equivalent to stretching their ranges (see Moore and Lee 1994). Stretch jth axis by weight zj , where z 1 ,... , zd chosen to minimize prediction error Use cross-validation to automatically choose weights z 1 ,... , zd Note setting zj to zero eliminates this dimension altogether
There has been a lot of recent work on learning distance metrics (Yang 2006, Davis et al. 2008, etc.)