代做Homework 2 Part 1代做Statistics统计

Homework 2

Part 1

PCA

1. PCA can be explained from two different perspectives. What are the two perspectives explained in class?

2. The first principal direction is the direction in which the projections of the data points have the largest variance in the input space. We use λ1 to represent the first/largest eigenvalue of the covariance matrix, w1 to denote the corresponding principal vector/direction (w1  has unit length i.e., its L2 norm is  1), μ to represent the sample mean, and x to represent a data point. The deviation of x from the mean μ is x − μ . The forward transform, y = PCA(x), is implemented in sk-learn with "whiten=True".

(1) write down the scalar-projection of the deviation x − μ in the direction of w1 ?

(2) what is the first component of y ?

note: compute it using w1   , x, μ ,  and λ1

(3) assuming y only has one component, then we do inverse transform. to recover the input

 ̃(x) = PCA−1(y)

computẽ(x) using μ, y, λ1  and w1

(4) assuming x andy have the same number of elements, and we do inverse transform to recover the input

 ̃(x) = PCA−1(y)

what is the value of x −̃(x) ?

Note: the question asks for a value/number, not equations

(5) For face image generation applications shown in class, what is the major difference between the two methods: eigenface vs. statistical shape model ?

Maximum Likelihood Estimation and NLL loss

(This is a general method to estimate parameters of a PDF using data samples)

3. Maximum Likelihood Estimation when the PDF is an exponential distribution.

We have Ni.i.d. (independently and identically distributed) data samples {x1, x2, x3, … , xN } generated from a PDF that is assumed to be an exponential distribution. xn  ∈ ℛ+ for n  = 1 to N, which means they are positive scalars. This is the PDF:

 

Your task is to build an NLL (negative log likelihood) loss function to estimate the parameter λ of the PDF from the data samples.

(1) write the NLL loss function: it is afunction of the parameter λ

(2) take the derivative of the loss with respect to λ , and set the result to 0. After some calculations, you will obtain an equation about λ  = ∗∗∗∗∗∗

Hint: read NLL in the lecture of GMM

4. Maximum Likelihood Estimation when the PDF is histogram-like.

A  histogram-like  PDF  f(x)  is  defined  on  a   1-dimensional  (1D)   space  that  is  divided  into  fixed regions/intervals.  So, f(x)  takes  constant  value   i    in  the  i-th  region.  There  are  K  regions.  Thus, {ℎ1, ℎ2, … , ℎk } is the set of (unknown) parameters of the PDF. Also,   iΔ i   = 1, where Δ i  is the width of the i-th region.

Now, we have a dataset of N samples {x1, x2, x3, … , xN }, and Ni  is the number of samples in the i-th region. The task is to find the best parameters of the PDF using the samples.

(1) write the loss function: it is a function of the parameters

Note: it is a constrained optimization problem, so we need to use the Lagrange multiplier method to convert constrained optimization to unconstrained optimization. Thus, we add λ(  iΔ i  − 1) and the NLL together to get the complete loss function, where λ is the Lagrange multiplier.

(2) take the derivative of the loss with respect to ℎ i , set it to 0, and obtain the best parameters along with the value of λ .

Is Bayes optimal ?

5. Bayes classifier has the minimum classification error assuming we know the true p(x|y) and p(y) . However, for many applications,  reaching the minimum classification error may not be the best objective. Now, let’s consider the application explained in the lecture:  there are two classes, class-0 and class-1.

In class-0, patients have aneurysms, but the aneurysms will not rupture

In class-1, patients have aneurysms, and the aneurysms will rupture almost immediately if left untreated, and therefore surgeries will be performed to prolong the life of the patients.

Assume these:

(a)  The patients in class-0 will live until the age of 100.

(b) The  patients  in  class-1  will  live  until  the  age  of  100  after  receiving  surgeries  but  will  die immediately if left untreated.

(c)  Ther risk of the surgery is ε between 0 and 1,e.g., ε=0.01 means there is a 1% chance that a patient may die during surgery.

Consider a patient at the age of 60, if the true class label of a patient is class-0, but this patient is misclassified to class-1, thus, this patient will get an unnecessary surgery and may die with the chance of ε . The average cost for this patient is 40×ε

Consider another patient at the age of 60, if the true class label of a patient is class-1, but this patient is misclassified to class-0, thus, this patient will not get surgery and die almost immediately. The cost of this misclassification is 40 years for this patient.

Now, we have data points {x1, x2, x3, … , xN } with true labels {y1, y2, y3, … , yN }, and xn  is the aneurysm

feature of the patient-n.  The current age of the patient-nistn.  We have this cost table for each patient:

True label yn

Predicted Label ̂(y)n

Cost for the patient-n

0

0

0

1

1

0

0

1

(100-tn)×ε

1

0

100-tn

̂(y)n  = f(xn; w) is a classification model with internal parameter w The value of ̂(y)n  isa real number between 0 and 1.

Your task: design a differentiable loss Ln(w) that is the cost of making a wrong classification on xn.

“differentiable” means  exists, so that  exists.

Part 2

Complete the task in H2P2T1.ipynb and H2P2T2.ipynb

Note: It is very time consuming to fit a GMM to high dimensional data, and therefore PCA + GMM is the "standard" approach.

Grading: the number of points

 

Undergraduate Student

Graduate Student

1 (PCA)

1

1

2 (PCA)

5

5

3 (NLL)

4

4

4 (NLL)

N.A.

5 bonus points

5 (loss)

10

10

H1P2T1

15

15

H2P2T2

15

15

Total number of points

50 +5

50 + 5

Extra Reading

PCA is widely used in many applications. Do a google scholar search with PCA + some field, e.g., PCA +bioinformatics or PCA + finance, you will find relevant papers.

https://www.nature.com/articles/s41467-018-04608-8

There are many variants of PCA, such as sparse PCA and kernel PCA that are implemented in sk-learn. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.7798&rep=rep1&type=pdf

https://www.di.ens.fr/sierra/pdfs/icml09.pdf

https://www.di.ens.fr/~fbach/sspca_AISTATS2010.pdf

Which one is good for your application?  Test different algorithms and find the best. Remember that machine learning is more like an experimental science: you need to run lots of experiments.


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图