Group coursework 2 Please submit your coursework on Moodle by Midday on 1st of March. Please upload your answers to Question 1 ii) and Question 2 in one pdf file. Please also upload three R scripts in .R files for Question 1 i), Question 1 ii) andQuestion 2. Make sure that you have included sufficient comments in the codes to make themreadable by other people. There should be no error messages shown when I runyour R scripts. You can assume that I have installed all required packages.Question 1 [8 marks]i) Complete the following myLDA function without using any additional packages.With the feature matrix X ∈ RN×p(N > p) and the label vector y ∈ RN×1 ofthe training data, the myLDA function outputs the linear discriminant w ∈ Rp×1forbinary classification.[6 marks]myLDA classification. Input: Feature matrix, X (N by p) and label vector, y (N by 1) Output: Linear discriminant, w (p by 1)return(w)}ii) Calculate the cosine of the angle between the linear discriminant calculated frommyLDA(X=iris[51:150,-5],y=iris[51:150,5]) and that calculated fromlda(Species~.,data=iris[51:150,]). [You can ignore the warning message fromlda that the setosa class is empty.]The cosine of the angle between two vectors, u ∈ Rp×1 and v ∈ Rp×1, is defined ascos(u, v) = u代写Moodle留学生作业、代做R程序语言作业、R课程设计作业代做、代写Linear作业 代写Web开发|代做SPSST v||u||2||v||2,where ||u||2 =√uTu and ||v||2 =√vT v.What conclusion can you make from this result? [2 marks]1Question 2 [12 marks]Download the newthyroid.txt data from moodle. This data contain measurements fornormal patients and those with hyperthyroidism. The first variable class=n if a patientis normal and class=h if a patients suffers from hyperthyroidism. The rest variablesfeature1 to feature5 are some medical test measurements.i) Draw a pairs plot for the newthyroid.txt data. What patterns can you see fromthis plot? [2 marks]ii) Apply kNN and LDA to classify the newthyroid.txt data: randomly split the datato a training set (70%) and a test set (30%) and repeat the random split 50 times.Record the 50 AUC values of kNN and LDA in two vectors.For kNN, repeat 5-fold cross-validation five times to choose k from (3, 5, 7, 9). UseAUC as the metric to choose k, i.e. choose k with the largest AUC. [5 marks]Hint: Read http://topepo.github.io/caret/model-training-and-tuning.html#model-training-and-parameter-tuning to see how to use AUC as the metric tochoose k.iii) For the first random split, draw the ROC curves of kNN and LDA on one plot.[2 marks]iv) Draw two boxplots based on the 50 AUC values of kNN and LDA. [1 mark]v) What conclusions can you make from the classification results of kNN and LDA onthe newthyroid.txt data? [2 marks]转自:http://ass.3daixie.com/2019022347964235.html
讲解:Moodle、R、R、LinearWeb|SPSS
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。