Question: give the code for this part(Cross validation). 4. Cross-validation: in class we talked about cross-validation (CV) as a way to select the best model by

  give  the code for this part(Cross validation).
4. Cross-validation: in class we talked about cross-validation (CV) as a way

4. Cross-validation: in class we talked about cross-validation (CV) as a way to select the best model by estimating "test error". In k-fold CV, each of k equally sized random partitions of data (chunks) are used in a heldout set (called validation set or test set). After k runs, we average the held-out error as our final estimate of the validation error. For this part, we will run cross-validation on only a single model, as a way to estimate our test error for future predictions (we are not using it here for model selection since we are considering only one model). Perform 6-fold cross-validation on this model to estimate the (average) test error. (a) First randomly partition data into 6 equal sized chunks. Use set.seed (10) before cut/sample. Hint: a simple way to randomly assign each observation to a chunk is to do the following. First, use cut (..., label=FALSE) to divide observation ids (1, 2, ...) into roughly equal numbers of chunk ids. Then, randomize output of cut () by using sample(). (b) Perform 6-fold cross-validation with training error and validation errors of each chunk determined from (4a). Since same computation is repeated 6 times, we can define the following function for simplicity. do. chunk

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!