代写Homework 1: ML 80629A代写留学生R语言

Homework 1: ML 80629A (FALL 2021)
Instructions:
• Please include your name and HEC ID with submission.
• The homework is due by 11:59pm on the due d
ate.
• The homework is worth 20% of the course’s final grade.
• Assignments are to be done individually.
• All code used to arrive at answers is submitted along with answers. You
can convert your jupyter notebook or colab to pdf and upload it.
1 ML Fundamentals (20pt)
1. (4pt) Explain the difference between the training error and the general-
ization error. Make sure to describe how to evaluate the generalization
error of a model in practice including pitfalls of this approach.
2. (4pt) To increase the size of your training set you first train a model and
then use it to obtain labels on an unlabelled test set. You then retrain
the model with the data from your train set as well as the data from your
test set.
Would you expect that your final model would obtain a lower validation
error?
3. (4pt) Suggest a method for regularization a K-NN model. Hint: think of
what regularization accomplishes in terms of the bias/variance trade off.
4. (4pt) Recall the task of document classification where documents must
be classified based on their content. If the documents are encoded in a
bag-of-words format, could you use K-NN to classify them? If so, describe
a distance function that might be sensible to use. Otherwise, explain why
not.
5. (4pt) Describe both the advantages and the disadvantages of using a larger
K when doing K-fold cross validation.
2 Regression (15pt)
• Let’s explore California housing dataset. This dataset was obtained from
the StatLib repository. The target variable is the median house value
for California districts, expressed in hundreds of thousands of dollars
($100,000). You can load the data from scikit-learn. You can use .DESCR
to gather more info about this dataset.
1. (2pt) Perform. statistical analysis by using .describe() on the data,
what do you notice about the attribute values?
2. (2pt) Look at the distribution of the attribute values by plotting their
histograms. Notice anything interesting?
3. (3pt) Perform. 10-fold cross-validation (with shuffle=True and random state=20160202)
with a LinearRegression model. Report the mean squared error
(MSE) on the validation set (averaged across folds).
• Two very popular options in Linear Regression are the Lasso method and
the Ridge Regression. These models are implemented in sklearn: Lasso
and Ridge.
Hint: If you’d like to understand Ridge Regression better, you might want
to look at this example.
4. (2pt) What one word captures what Lasso and Ridge do?
5. (3pt) Perform. 10-fold CV with normal LinearRegression, Lasso, and
Ridge. Compare the attribute weights (coef) of each of these meth-
ods. What do you observe?
6. (3pt) Report the average MSE for each method on the validation
set across folds. How do these variants of linear regression perform
compared to each other?
Classification (65 pt)
In this exercise, you will implement Naive Bayes classifier and neural network
models to carry out a text classification task. You will implement various fea-
ture representations, i.e., BoW and TF-IDF and then you will do performance
analysis of NNs and NB with different hyperparameter settings.
The data to download is movie reviews dataset. In each file (train, vali-
dation, test), each line consists of a single review text followed by a number
indicating the sentiment : 0 for negative and 1 for positive. You would have to
split the these data into input texts and corresponding labels.Hint: you can use
the function split(’\t’), pandas allows you to easily use this data.
3 Feature Representations (5pt)
Transform. the input text data into the following feature representations to train
some models. You can use scikit-learn tools to do this. To reduce the time for
training, please set max-features = 10000 to build a vocabulary that only
consider the 10k top max features ordered by term frequency across the corpus.
Do not change the other parameters.
For this question, we ask you for the few lines of code from sklearn that you
used to encode (and only encode) the training, validation and test data into
(use the default settings):
1. (3pt) Bag-of-Words features (BoW)
2. (2pt) TF-IDF features
4 Naive Bayes (15pt)
1. (5pt) Perform. the sentiment classification task with these 2 different types
of features. Report which NB you used and what is the validation set
accuracy in each case.
2. (10pt) Based on the classification of the model, report 5 words from the
texts in the train dataset that can be inferred as positive and 5 words that
are negative.
5 Neural Network (30pt)
After all the required imports in your code be sure to set the random state=12345.
1. (12pt) From the BoW and TF-IDF features from above, you are going to
train different neural network models. Use the option early stopping=True
and train the networks by trying all the following hyperparameter combi-
nations:
• dimension of a first hidden layer: [4,8,16]
• dimension of a second hidden layer: [0,4,8]
• learning rate (after fixing the above three hyperparameters): [0.1,
0.01, 0.001]
• L2 (penalty): [0.001, 0.01, 0.1]
What is the best combination of hyperparameters and what is the perfor-
mance on the resulting model validation set?
2. (16pt) What did you observe with the impact of different hyperparame-
ters on the model accuracy? Write a brief recommendation to follow for
someone trying to find the best hyprparameters for their model.
3. (2 pt) Can you recommend any other hyperparameters to tune?
6 Comparison (15pt)
1. (4pt) Determine the performance of the simplest baseline, i.e., majority
voting, for this task.
2. (5pt) For each case of the feature representation (BoW and TF-IDF),
report the best test performance accuracies of the Naive Bayes classifier
and Neural Network that you observe.
3. (3pt) Based on these accuracy values, which is the best feature represen-
tation for each type of model that we have considered? Can you think of
why this is the case?
4. (3pt) Based on these accuracy values, which is the best performing model?
Explain briefly why it is the case.




热门主题

课程名

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