pattern recognition professor aly a. farag computer vision and image processing laboratory...

43
PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL: www.cvip.uofl.edu ; E-mail: [email protected] Planned for ECE 620 and ECE 655 - Summer 2011 TA/Grader: Melih Aslan; CVIP Lab Rm 6, [email protected] Lecture 15 – Non Parametric Methods

Upload: marian-black

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

PATTERN RECOGNITION

Professor Aly A. FaragComputer Vision and Image Processing Laboratory

University of LouisvilleURL: www.cvip.uofl.edu ; E-mail: [email protected]

Planned for ECE 620 and ECE 655 - Summer 2011TA/Grader: Melih Aslan; CVIP Lab Rm 6, [email protected]

Lecture 15 – Non Parametric Methods

Page 2: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Introduction

All Parametric densities are unimodal (have a single local maximum), whereas many practical problems involve multi-modal densities

Nonparametric procedures can be used with arbitrary distributions and without the assumption that the forms of the underlying densities are known

There are two types of nonparametric methods:

Estimating P(x | j ) Bypass probability and go directly to a-posteriori probability

estimation

Page 3: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 3

Density Estimation

Basic idea:

Probability that a vector x will fall in region R is:

P is a smoothed (or averaged) version of the density function p(x) if we have a sample of size n; therefore, the probability that k points fall in R is then:

and the expected value for k is:

E(k) = nP (3)

(1) 'dx)'x(pP

(2) )P1(P k

nP knk

k

Page 4: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 4

ML estimation of P = is reached for

Therefore, the ratio k/n is a good estimate for the probability P and hence for the density function p.

p(x) is continuous and that the region R is so small that p does not vary significantly within it, we can write:

where is a point within R and V the volume enclosed by R.

)|P(Max k

Pn

(4) V)x(p'dx)'x(p

Page 5: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 5

Combining equation (1) , (3) and (4) yields:

V

n/k)x(p

Page 6: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 6

Density Estimation (cont.)

Justification of equation (4)

We assume that p(x) is continuous and that region R is so small that p does not vary significantly within R. Since p(x) = constant, it is not a part of the sum.

(4) V)x(p'dx)'x(p

Page 7: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 7

Where: (R) is: a surface in the Euclidean space R2

a volume in the Euclidean space R3

a hypervolume in the Euclidean space Rn

Since p(x) p(x’) = constant, therefore in the Euclidean space R3:

)()'x(p'dx)x(1)'x(p'dx)'x(p'dx)'x(p

nV

k)x(p and

V).x(p'dx)'x(p

Page 8: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 8

Condition for convergence

The fraction k/(nV) is a space averaged value of p(x). p(x) is obtained only if V approaches zero.

This is the case where no samples are included in R: it is an uninteresting case!

In this case, the estimate diverges: it is an uninteresting case!

fixed)n (if 0)x(plim0k ,0V

)x(plim0k ,0V

Page 9: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 9

The volume V needs to approach 0 anyway if we want to use this estimation

Practically, V cannot be allowed to become small since the number of samples is always limited

One will have to accept a certain amount of variance in the ratio k/n

Theoretically, if an unlimited number of samples is available, we can circumvent this difficultyTo estimate the density of x, we form a sequence of regions

R1, R2,…containing x: the first region contains one sample, the second two samples and so on.

Let Vn be the volume of Rn, kn the number of samples falling in Rn and pn(x) be the nth estimate for p(x):

pn(x) = (kn/n)/Vn (7)

Page 10: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 10

Three necessary conditions should apply if we want pn(x) to converge to p(x):

There are two different ways of obtaining sequences of regions that satisfy these conditions:

(a) Shrink an initial region where Vn = 1/n and show that

This is called “the Parzen-window estimation method”

(b) Specify kn as some function of n, such as kn = n; the volume Vn is

grown until it encloses kn neighbors of x. This is called “the kn-nearest

neighbor estimation method”

0n/klim )3

klim )2

0Vlim )1

nn

nn

nn

)x(p)x(pn

n

Page 11: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 11

Page 12: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu
Page 13: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 13

Parzen Windows

Parzen-window approach to estimate densities assume that the region Rn is a d-dimensional hypercube

((x-xi)/hn) is equal to unity if xi falls within the hypercube of volume Vn centered at x and equal to zero otherwise.

otherwise0

d , 1,...j 2

1u 1

(u)

:functionwindow following the be (u) Let

) ofedge the of length :(h hV

j

nndnn

Page 14: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 14

The number of samples in this hypercube is:

By substituting kn in equation (7), we obtain the following estimate:

Pn(x) estimates p(x) as an average of functions of x and the samples (xi) (i = 1,… ,n). These functions can be general!

ni

1i n

in h

xxk

n

ini

1i nn h

xx

V1

n1

)x(p

Page 15: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 15

Illustration

The behavior of the Parzen-window method

Case where p(x) N(0,1)

Let (u) = (1/(2) exp(-u2/2) and hn = h1/n (n>1)

(h1: known parameter)

Thus:

is an average of normal densities centered at the samples xi.

n

ini

1i nn h

xx

h

1

n

1)x(p

Page 16: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 16

Numerical results:

For n = 1 and h1=1

For n = 10 and h = 0.1, the contributions of the individual samples are clearly observable !

)1,x(N)xx(e2

1 )xx()x(p 1

21

2/111

Page 17: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 17

Page 18: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 18

Page 19: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 19

Analogous results are also obtained in two dimensions as illustrated:

Page 20: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 20

Page 21: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 21

Case where p(x) = 1.U(a,b) + 2.T(c,d) (unknown density) (mixture of a uniform and a triangle density)

Page 22: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 22

Page 23: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 23

Classification example

In classifiers based on Parzen-window estimation:

We estimate the densities for each category and classify a test point by the label corresponding to the maximum posterior

The decision region for a Parzen-window classifier depends upon the choice of window function as illustrated in the following figure.

Page 24: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Ch4 (Part 1) 24

Page 25: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Chapter 4 (part 2):Non-Parametric Classification (Sections 4.3-4.5)

Parzen Window (cont.)

Kn –Nearest Neighbor Estimation

The Nearest-Neighbor Rule

Page 26: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 26

Parzen Windows (cont.)

Parzen Windows – Probabilistic Neural Networks

Compute a Parzen estimate based on n patterns

Patterns with d features sampled from c classesThe input unit is connected to n patterns

.x1

x2

xd

.

.

.

p1

p2

pn

.

.

.

Input unit Input patterns

.

. ..

Modifiable weights (trained)

Wdn

Wd2

W11. .

Page 27: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 27

p1

p2

pn

.

.

.

Input patterns

pn

pk... .

.

.

.1

2

c...

Category units

.

.

.

Activations (Emission of nonlinear functions)

Page 28: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 28

Training the network

Algorithm

1. Normalize each pattern x of the training set to 1

2. Place the first training pattern on the input units

3. Set the weights linking the input units and the first pattern units such that: w1 = x1

4. Make a single connection from the first pattern unit to the category unit corresponding to the known class of that pattern

5. Repeat the process for all remaining training patterns by setting the weights such that wk = xk (k = 1, 2, …, n)

We finally obtain the following network

Page 29: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 29

Page 30: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 30

Testing the network

Algorithm

1. Normalize the test pattern x and place it at the input units2. Each pattern unit computes the inner product in order to

yield the net activation

and emit a nonlinear function

3. Each output unit sums the contributions from all pattern units connected to it

4. Classify by selecting the maximum value of Pn(x | j) (j = 1, …, c)

x.wnet tkk

2

kk

1netexp)net(f

)x|(P)|x(P j

n

1iijn

Page 31: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 31

Kn - Nearest neighbor estimation

Goal: a solution for the problem of the unknown “best” window function

Let the cell volume be a function of the training dataCenter a cell about x and let it grows until it captures kn samples

(kn = f(n))kn are called the kn nearest-neighbors of x

2 possibilities can occur:

Density is high near x; therefore the cell will be small which provides a good resolution

Density is low; therefore the cell will grow large and stop until higher density regions are reached

We can obtain a family of estimates by setting kn=k1/n and choosing different values for k1

Page 32: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 32

Illustration

For kn = n = 1 ; the estimate becomes:

Pn(x) = kn / n.Vn = 1 / V1 =1 / 2|x-x1|

Page 33: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 33

Page 34: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 34

Page 35: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 35

Estimation of a-posteriori probabilities

Goal: estimate P(i | x) from a set of n labeled samples

Let’s place a cell of volume V around x and capture k sampleski samples amongst k turned out to be labeled i then:

pn(x, i) = ki /n.V

An estimate for pn(i| x) is:

k

k

),x(p

),x(p)x|(p i

cj

1jjn

inin

Page 36: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 36

ki/k is the fraction of the samples within the cell that are labeled i

For minimum error rate, the most frequently represented category within the cell is selected

If k is large and the cell sufficiently small, the performance will approach the best possible

Page 37: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 37

The nearest –neighbor rule

Let Dn = {x1, x2, …, xn} be a set of n labeled prototypes

Let x’ Dn be the closest prototype to a test point x then the nearest-neighbor rule for classifying x is to assign it the label associated with x’

The nearest-neighbor rule leads to an error rate greater than the minimum possible: the Bayes rate

If the number of prototype is large (unlimited), the error rate of the nearest-neighbor classifier is never worse than twice the Bayes rate (it can be demonstrated!)

If n , it is always possible to find x’ sufficiently close so that: P(i | x’) P(i | x)

Page 38: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 38

Example:x = (0.68, 0.60)t

Decision: 5 is the label assigned to x

Prototypes Labels A-posteriori probabilities estimated

(0.50, 0.30)

(0.70, 0.65)

23

56

0.250.75 = P(m | x)

0.700.30

Page 39: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 39

If P(m | x) 1, then the nearest neighbor selection is almost always the same as the Bayes selection

Page 40: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 40

Page 41: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 41

The k – nearest-neighbor rule

Goal: Classify x by assigning it the label most frequently represented among the k nearest samples and use a voting scheme

Page 42: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 42

Page 43: PATTERN RECOGNITION Professor Aly A. Farag Computer Vision and Image Processing Laboratory University of Louisville URL:  ; E-mail: aly.farag@louisville.edu@louisville.edu

Pattern Classification, Chapter 4 (Part 2) 43

Example:k = 3 (odd value) and x = (0.10, 0.25)t

Closest vectors to x with their labels are:{(0.10, 0.28, 2); (0.12, 0.20, 2); (0.15, 0.35,1)}

One voting scheme assigns the label 2 to x since 2 is the most frequently represented

Prototypes Labels

(0.15, 0.35)(0.10, 0.28)(0.09, 0.30)(0.12, 0.20)

1252