Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Homework 1

Answer the following questions using R.

Submitted homework solutions should be well written and should include all R code and R output. R Markdown is a useful tool for doing this nicely. But you may also use knitr. If you think you are up to it.

(Book Link: https://hastie.su.domains/ISLR2/ISLRv2 website.pdf)

Due: September 9, 2023

1.  Page 52, Ex. 2.

2.  Page 52, Ex. 4. Parts A and B only.

3.  Page 52, Ex. 5.

4.  (UNDERGRAD ONLY) Download the data set College” using this link: http://bit.ly/30C2DMz. This le will be in .csv format. Use this data to answer Ex. 8 on page 54.

5.  The training data (http://bit.ly/340jDyc) set contains 175 observations classified as red or green. The test data set (http://bit.ly/2L7uhdO) con- tains 1750 observations classified as either red or green.

● Perform k-nearest neighbor classification using the training data with k = 1.  Use this model to predict the class of each observtion in the training data set. How many observations were incorrectly classified? Is this good?

● Again using k = 1, build a classification model with the training data set and use it to classify the observations in the test data set.  How many obervations were incorrectly classified? Is this good?

●  (GRAD ONLY) Train a model for for each value of k between 1 and

100.   For each model, predict the class of the observations in the trainnig data set and the observations in the test data set.   Make a plot of the value of k on the x-axis and the error rate on the y- axis. (This is similar to Figure 2.4 in the book Elements of Statistical Learning) Comment on this graph.

6.  Plot all irises based on their Sepal.Length and Sepal.Width values using different colors for each species.

7.  Perform linear discriminant analysis using the iris data with only Sepal.Length and Sepal.Width as predictors. Make predictions about the species of each

iris and create a confusion matrix for this predictions.

8.  (GRAD ONLY) On the plot produced in part 1, plot the predicted value of species over a grid of points using the same color scheme used in part 1.