代做CSC646-B - Introduction to Machine Learning with Applications代做Python编程

CSC646-B - Introduction to Machine Learning with Applications

Part-1: Basic Concepts

1. Cross-entropy loss for classification (18 points)

Notations for (1) and (2):

xn  isan input data sample, and it is a vector.

yn  is the ground-truth class label of xn.

̂(y)n  is the output “soft-label”/confidence of a logistic regression classifier given the input xn

The number of classes is K

(1: 1 point) Assume there are only two classes (K=2): class-0, class-1, and the data point xn  is in class-1 (yn =  1). Assume the output is ̂(y)n  = 0.9 from a binary logistic regression classifier.

Compute the binary cross-entropy loss associated with the single data sample xn. note: show the steps of your calculations. You will get zero point if only a number is shown.

(2: 1 point) Assume there are three classes (K=3): class-0, class-1 and class-2, and the data point xn  is in class-2 (yn  = 2). Assume the output is ̂(y)n =  [0.01, 0.09, 0.9]T  from a multi-class logistic regression classifier.  Do one-hot- encoding on yn , and then Compute the cross-entropy loss associated with the single data sample xn.

note: show the steps of your calculations. You will get zero point if only a number is shown.

Show that the function is convex in x, where  log is the natural log .

Here is a plot of the function, and it seems that the function is convex.

Hint: show that then it is convex.

Note:  show the steps of your calculations

(4: 2 points) Explain why cross entropy loss is convex with respect to the parameters of a logistic regression classifier.

Note: a few bullet points are just fine, and you may use anything in the lecture notes.

(5: 5 points) Let L be the cross entropy loss of a logistic regression classifier for binary-class classification, and let ̂(y)

be the scalar output of the classifier for an input sample x. and z  = W Tx + b. Compute the derivative

note: show the steps of your calculations. You will get zero point if only the result is shown.

(6: 7 points) Let L be the cross entropy loss of a logistic regression classifier for multi-class classification, and let̂(y)

be the vector output of the classifier for an input sample x.  ̂(y) = softmax(z) , where z =  [z1, … , zk ]T  and zk = Wk(T)x + bk .  Compute the derivative which is a vector.

note: show the steps of your calculations. You will get zero point if only the result is shown.

Note: this results of (5) and (6) are very useful when we apply the cross entropy loss to neural networks.

2. Regression with multiple outputs (3 points)

xn  isan input data sample, and it is a vector.

yn  is the ground-truth .

yn  is a vector and it has two elements [yn, 1 , yn,2]. For example, yn, 1  is income, and yn,2  is age.

̂(y)n  is the output of a regressor (e.g., linear regressor) given the input xn   .

yn  is a vector and it has two elements [̂(y)n, 1 ,̂(y)n,2].

There are N data points.

(1: 1 point) write down the formula of MSE loss, using yn, 1 , yn,2 ,̂(y)n, 1 ,̂(y)n,2 , and N, where n is from 1 to N

(2: 1 point)  write down the formula of MAE loss, using yn, 1 , yn,2 ,̂(y)n, 1 ,̂(y)n,2 , and N, where n is from 1 toN

(3: 1 point)  write down the formula of MAPE loss, using yn, 1 , yn,2 ,̂(y)n, 1 ,̂(y)n,2 , and N, where n is from 1 toN

Note: the loss in (1)/(2)/(3) is the total loss calculated using all of the samples (nis from 1 toN)

3. Decision Tree (5 points)

A decision tree is a partition of the input space.

Every leaf node of the tree corresponds to a region of the final partition of the input space.

(1)~(5) are related to the tree below:

(1: 1 point) What is the total number of training samples according to the above tree for classification? (2: 1 point) What is the max-depth of the tree?

(3: 1 point) What is the entropy on Node-0?  (using log base 2)

(4: 1 point) How many pure’ nodes (entropy =0) does this tree have? (5: 1 point) How many leaf/terminal nodes does this tree have?

4. Bagging and Random Forest (2 points)

(1: 1 point) Bagging will NOT work under a condition: what is this condition?

(2: 1 point) The trees in arandom-forest is only weakly correlated in theory: why?

5. Boosting (2 points)

What is the difference between boosting (e.g., XGBoost) and bagging (e.g., Random-forest) from the perspective of variance and bias?

6. Stacking (2 points)

(1: 1 point) Could it be useful to stack many polynomial models of the same degree? (2: 1 point) Could it be useful to stack models of different types/structures?

7. Overfitting and Underfitting ( 2 points)

It is easy to understand Overfitting and Underfitting, but it is hard to detect them.

Consider two scenarios in a classification task:

(1) the training accuracy is 100% and the testing accuracy is 50%

(2) the training accuracy is 80% and the testing accuracy is 70%

In which scenario is overfitting likely present? (1 point)

Consider two new scenarios in a classification task:

(1) the training accuracy is 80% and the testing accuracy is 70%

(2) the training accuracy is 50% and the testing accuracy is 50%

In which scenario is underfitting likely present? (1 point)

Keep in mind that, in real applications, the numbers in different scenarios maybe very similar.

We can always increase model complexity to avoid underfitting.

We need to find the model with the right” complexity (i.e., the best hyper-parameters) to reduce overfitting if possible.

8.  Training, Validation, and Testing for Classification and Regression ( 3 points)

(1: 1 point) What are hyper-parameters of a model? Give some examples.

(2: 1 point) Why do we need a validation set? Why don't we just find the optimal hyper-parameters of a model on the training set? e.g., find the model that performs the best on the training set.

(3: 1 point) Why don't we optimize the optimal hyper-parameters of a model using the testing set? Terminologies: training(train) set(dataset), testing(test) set(dataset), validation (val) set(dataset)

9. SVM (3 points)

(1: 1 point) Why maximizing the margin in the input space will improve classifier robustness against noises?

(2: 1 point) Will the margin in the original input space be maximized by a nonlinear SVM?

(3: 1 point) What is the purpose of using a kernel function in a nonlinear SVM?

10. Handle class-imbalance for classification tasks (2 points)

We have a class-imbalanced dataset, and the task is to build a classifier on this dataset. From the perspective of PDF, there are two types/scenarios of class-imbalance (see lecture notes). Now, assume we are in scenario-1.

(1: 1 point) Why do we use weighted-accuracy (a.k.a. balanced-accuracy) to measure the performance of a classifier? i.e., What is the problem of the standard accuracy?

(2:  1 point) When class-weight is not an option for a classifier, what other options do we have to handle class- imbalance?

11. Handle data-imbalance for regression tasks (2 points)

For regression tasks, is there an issue similar to class-imbalance ? If so, describe the issue and list some possible methods to handle this issue. (read http://dir.csail.mit.edu/)

12. Entropy (6 points)

The PMF for a discrete random variable X is [p1, p2, p3, … pk ] where ∑k pk   =  1 and 0 ≤ pk   ≤  1 Write down the entropy and prove that:

(1: 1 point)  entropy is non-negative

(2: 5 points)  entropy reaches the maximum when the PMF isa uniform distribution, i.e., pk   =  1/k Hint: you can use Jensen's inequality or Lagrange Multiplier

13. KL Divergence for probability distributions of discrete random variables. (5 points) There are two probability distributions for the same discrete random variable  X:

Distribution P:  [p1, p2, p3, … pk ] where k pk   = 1 and 0 ≤ pk  ≤ 1

Distribution Q:  [q1, q2, q3, … qk ] where ∑kqk   =  1 and 0 ≤ qk   ≤ 1

The KL Divergence measures the difference between P and Q, and it is defined as k

(1: 2 points) prove that the KL Divergence is non-negative Hint: you can use Jensen's inequality

(2: 3 points) show that the KL Divergence is equivalent to cross-entropy when the distribution P is known Hint: read lecture notes

Part-2: Programming on classification and regression

Read the instructions in H3P2T1.ipynb, H3P2T2.ipynb, H3P2T3.ipynb Grading: (points for each question/task)

Undergraduate Student

Graduate Student

Question 1

18

18

Question 2

3

3

Question 3

5

5

Question 4

2

2

Question 5

2

2

Question 6

2

2

Question 7

2

2

Question 8

3

3

Question 9

3

3

Question 10

2

2

Question 11

2

2

Question 12

Bonus (6 points)

6

Question 13

NA

Bonus (5 points)

H3P2T1

25

25

H3P2T2

21

15

H3P2T3

10

10

Attention:

If you use test sets for optimizing any model, you will get zero score.

Make sure you run each and every code cell of your program files. If you do not run a code cell, you will lose the points of that cell.

LLM (e.g. ChatGPT) may give you wrong answers.






热门主题

课程名

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
站长地图