CpE646 8v3 PDF
CpE646 8v3 PDF
CpE646 8v3 PDF
kn-Nearest-Neighbor
Nearest Neighbor Estimation
kn nearest-neighbor
g illustration
For kn = n when n=1, k1=1, and the estimate is
1
pn ( x) =
2 | x x1 |
where x1 is the first training sample, and || is a distance
measure. 2|x
| - x1| is the volume. This is not a ggood
estimate (Figure 4.12)
As n increases, the estimate gets better.
This method will not generate zero p(x) for any x. (If a
fixed window, e.g. Parzen window, is used and no
sample falls inside this window,
window the density estimate for
this window will be zero. This will not happen here.)
kn-Nearest Neighbor Estimation
kn-Nearest Neighbor Estimation
kn-Nearest Neighbor Estimation
ki/k is the fraction of the samples within the cell that are
l b l d j, i.e.
labeled i k samplesl ini the
th cell
ll andd ki outt off k are
labeled j
For minimum error rate,, the most frequently
q y
represented category within the cell is selected for this
cell, and any test sample lies in this cell is labeled as
this category.
category
The Nearest Neighbor Rule
To solve Pn((e||x, x)
We have n pairs of random variables {(x1,1),
(x2,2), , (xn,n)}, where j is class label for xj and
j {
{ 1, 2, , c}
Because the state of nature when xn (the nearest
e g bo of
neighbor o xw when
e tota
total sample
sa p e iss n) iss ddrawn
aw iss
independent of the state of nature when x is drawn,
we have
P( , n' | x, xn' ) = P ( | x) P( n' | xn' )
The Nearest Neighbor Rule
c
lim Pn (e | x) = 1 P(i | x) P (i | xn' ) ( xn' x)dxn'
n
i =1
c
= 1 P 2 (i | x)
i 1
i=
The Nearest Neighbor Rule
li Pn (e | x) p ( x)dx
= lim d
n
c
= 1 P (i | x) p ( x)dx
2
i =1
The error rate is bounded (proof in Sec 4.5.3)
c *
P P P 2
* *
P
c 1
The Nearest Neighbor Rule
The k-Nearest Neighbor Rule
Example
p
k = 3 (odd value) and
Prototypes Labels
x = (0.10, 0.25)t
(0.15,
(0 15 0.35)
0 35) 1
(0.10, 0.28) 2
(0 09 0.30)
(0.09, 0 30) 1
(0.12, 0.20) 2
3 closest vectors to x with their labels are:
{(0.10, 0.28; 2); (0.12, 0.20; 2); (0.15, 0.35; 1)}
The majority
j y votingg scheme will assignsg the label 2 to x.
Metrics and Nearest Neighbor Classification
n1 + n2 2n12
DTanimoto ( S1 , S 2 ) =
n1 + n2 n12
Tangent
g distance classifier is to use a novel distance
measure and a linear approximation to the arbitrary
transforms.
Assume
A a classifier
l ifi needs d to
t handle
h dl r transforms,
t f suchh
as horizontal translation, vertical translation, shear,
rotation, scale and line thinning
We take each prototype xand perform each of the
transforms Fi(x; i) where i is the parameter
associated with this transform,
transform such as the angle in
rotation.
Metrics and Nearest Neighbor Classification
A tangent
g vector TVi is constructed for each transform
TVi = Fi(x; i) - x
For each d-dimensional prototype x, an rd matrix T
is generated, consisting of the tangent vectors at x.
These vectors are linearly independent.
The prototype plus a linear combination of all tangent
vectors forms an approximation of an arbitrary
transform.
Metrics and Nearest Neighbor Classification
Metrics and Nearest Neighbor Classification
The tangent
g distance from a test point
p x to a pparticular
stored prototype x is defined as
Dtan(x, x) = mina [||(x + Ta) - x||]
where T is a matrix consisting of the r tangent vectors
at x, a is a vector of parameters for linear
combination,
co a d |||| can
b at o , and ca be Euclidean
uc dea distance.
d sta ce.
In classification of x, we will first find its tangent
distance to x by finding the optimizing value of a.
Thi minimization
This i i i i is i quadratic,
d i andd can be b done
d using
i
iterative gradient descent.
Metrics and Nearest Neighbor Classification