Docsity

Density Estimation and Classification - Homework 3 | CSCI 3202, Assignments of Computer Science

Toggle sidebar
bg1
CSCI 3202: Homework 3
Assigned: Oct 26, 2006
Due: Nov. 30, 2006
This assignment is work 40% of your final mark.
You are free to discuss this homework with anyone you like. However the assignment you hand in
must be your own. You must use Matlab!
You MUST use the template code in Template Code.zip for your assignment!
1 Density Estimation and Classification
The density estimation algorithm you will be implementing is based on a classification algorithm developed
by Thomas Strohmann for his Ph.D. proposal. One motivation behind this algorithm is that it is intended to
be effective for very large problem domains.
YOU SHOULD MAKE AN EFFORT TO MAKE YOUR CODE AS OPTIMIZED AS POSSIBLE!!
1.1 Mixture of Gaussians: Estimating the Density of a Class
Assume a set of Nktraining example inputs from class k∈ {1, ..., K}, labeled as {xk
1, ..., xk
Nk}, where
xk
j= (xk
j1, ..., xk
jd)∈ <d, for all j= 1, ..., Nk(and d= 1,2, ...). Assume that these training examples are
generated i.i.d from a probability density function (pdf)hk(x). We will estimate this pdf for class kusing
the following mixture of Gaussians Model:
ˆ
hk(x) = 1
Nk
Nk
X
j=1
1
r(2π)d¯¯¯ˆ
Σkj ¯¯¯
exp ·−1
2³x−xk
j´Tˆ
Σ−1
kj ³x−xk
j´¸
(1)
where ˆ
Σkj is the covariance matrix of Gaussian jof class k,ˆ
Σ−1
kj is its inverse, and |ˆ
Σ−1
kj |is its determinant.
The covariance matrix ˆ
Σkj is estimated using the Qnearest neighbors of xk
jin the training {xk
1, ..., xk
Nk}.
For notational convenience, we label the points xk
jand its Qnearest neighbors as {p1, ..., pQ}, where
pq= (pq1, ..., pqd). Given {p1, ..., pQ}, we estimate ˆ
Σkj as:
ˆ
Σkj =
σ2
kj10
...
0σ2
kjd
(2)
where, ∀m∈ {1, ..., d},
σ2
kjm =d[max {Smin ,var(pm)}]
Smin >0
var (pm) = 1
Q−1
Q
P
i=1
(pim −¯pm)2
¯pm=1
Q
Q
P
i=1
pim
(3)
1
pf3

Partial preview of the text

Download Density Estimation and Classification - Homework 3 | CSCI 3202 and more Assignments Computer Science in PDF only on Docsity!

CSCI 3202: Homework 3

Assigned: Oct 26, 2006

Due: Nov. 30, 2006

This assignment is work 40% of your final mark.

You are free to discuss this homework with anyone you like. However the assignment you hand in

must be your own. You must use Matlab!

You MUST use the template code in Template Code.zip for your assignment!

1 Density Estimation and Classification

The density estimation algorithm you will be implementing is based on a classification algorithm developed

by Thomas Strohmann for his Ph.D. proposal. One motivation behind this algorithm is that it is intended to

be effective for very large problem domains.

YOU SHOULD MAKE AN EFFORT TO MAKE YOUR CODE AS OPTIMIZED AS POSSIBLE!!

1.1 Mixture of Gaussians: Estimating the Density of a Class

Assume a set of N k

training example inputs from class k ∈ { 1 , ..., K}, labeled as {x

k

1

, ..., x

k

N k

}, where

x

k

j

= (x

k

j 1

, ..., x

k

jd

d , for all j = 1, ..., N k

(and d = 1, 2 , ...). Assume that these training examples are

generated i.i.d from a probability density function ( pdf ) h k

(x). We will estimate this pdf for class k using

the following mixture of Gaussians Model:

h k

(x) =

N

k

Nk ∑

j=

  

  

√

(2π)

d

∣

∣

∣

kj

∣

∣

∣

exp

[

(

x − x

k

j

) T

ˆ Σ

− 1

kj

(

x − x

k

j

)

]

  

  

where

Σkj is the covariance matrix of Gaussian j of class k,

− 1

kj

is its inverse, and |

− 1

kj

| is its determinant.

The covariance matrix

kj

is estimated using the Q nearest neighbors of x

k

j

in the training {x

k

1

, ..., x

k

Nk

For notational convenience, we label the points x

k

j

and its Q nearest neighbors as {p 1 , ..., pQ}, where

pq = (pq 1 , ..., pqd). Given {p 1 , ..., pQ}, we estimate

Σkj as:

kj

σ

2

kj 1

0 σ

2

kjd

where, ∀m ∈ { 1 , ..., d},

σ

2

kjm

= d [max {S min

, var (p m

)}]

S

min

var (p m

1

Q− 1

Q ∑

i=

(p im

− p¯ m

2

p ¯ m

1

Q

Q ∑

i=

p im

Given this simplified form for

kj

, we can write

h k

(x) as:

hk (x) =

N

k

N k ∑

j=

      

      

√

√

√

√ (2π)

d

(

d ∏

i=

σ

2

kji

)

exp

−

d ∑

i=

(

x

k

ji

− x i

) 2

σ

2

kji

      

      

For computational reasons, this equations is implemented as:

hk (x) =

1

N k

N ∑k

j=

{exp [Akj (x) − Bkj ]}

Akj (x) = −

1

2

d ∑

i=

(x

k

ji

−xi)

2

σ

2

kji

B

kj

d

2

log e

(2π) +

d ∑

i=

log e

(σ kji

The learning parameters Q > 1 and S min

0 are estimated using a validation set as defined below.

1.2 Classification From Density Estimation

Given estimates of pdfs

hk(x) and prior class probabilities pˆk, we use the Bayes optimal classifier:

y ˆ = arg max

k∈{ 1 ,...,K}

{

p ˆ k

h k

(x)

}

where pˆ k

is the proportion of training data belonging to class k.

1.3 Scaling the Data

The training data {x

k

1

, ..., x

k

N k

} for each class is scaled such that each dimension has mean zero and a

standard deviation of one. THIS MEANS THAT BEFORE A TEST OR VALIDATION POINT x is applied

to

h k

(x), it must be scaled by the same scaling factors! To scale dimension x i

the following is used:

xi ⇐

x i

− x¯

k

i

sd

(

x

k

i

where x¯

k

i

is the mean value of dimension i in {x

k

1

, ..., x

k

N k

} and sd(x

k

i

) is its standard deviation.

1.4 Choosing Q > 1 and Smin > 0

Assume that, for each class there is a training set X

k

trn

= {x

k

1

, ..., x

k

Nk

}, and a validation set X

k

val

v x

k

1

v x

k

N

v

k

} consisting of N

v

k

points. The validation sets will be used to pick Q > 1 and Smin > 0.

This will be done by searching over Q ∈ { 5 , 15 , 25 , 35 }; for each value of Q, and choosing the best

S

min

∈ { 1 e − 10 , 1 e − 6 , 1 e − 2 }. The parameters Q and S min

will be chosen using Maximum Likelihood

as follows.

Maximizing the Likelihood of the Validation Data in the Class: The likelihood function of

h k

(x) on

the validation data X

k

val

v x

k

1

v x

k

N

v

k

} is given by:

L

(

h k

∣

∣

∣

(

v x

k

1

v x

k

N

v

k

) )

N

v

k ∏

t=

h k

(

v x

k

t

)