Homework 08: Neural Nets

Due Friday, April 21

2023-02-13

Instructions

For this homework, you should create a new folder in your homework directory. Call it HW8 or something similar that you can keep track of. Download the homework markdown template file Student_HW_template.Rmd from the course webpage, and put a copy in this folder. Rename it something like HW8_YourName.Rmd. This markdown document will be where you will answer each of the questions below.

The Assignment

You are going to use the Chicago data set on daily CTA ridership to predict the total ridership on a given day. We introduced this dataset when we studied single layer NNs.

  1. Take a look at the variables in the dataset and make sure you understand what’s there. Provide a few plots of interesting variables, and see how they are connected with the output. Do you expect that any of the variables are correlated?

  2. Make training and test splits (note that this data has a time component, take that into account in your split). Create a recipe to use this data with neural nets. Describe and justify any preprocessing steps you chose.

  3. Create an MLP model specification using the keras engine. Set epochs=100, and set the hidden_units and penalty to tune(). Use the ReLU activation function.

  4. What are the default ranges that tune_grid will search for these parameters? (recall chapter 12.6 of TMWR). Update these so that hidden_units ranges from 5 to 15.

  5. Tune the model. This may take a long time, so you may want to test your code out with a small number of repeats, or a small grid before doing a full run. Report the best parameters and the test set metrics. You may want to save objects to avoid the knitting taking forever.

  6. Make an autoplot of the performance of your model for different combinations of parameters. Select the best parameters and finalize your workflow.

  7. Report the test set metrics. (I got \(R^2 = .878\) and RMSE = \(2.39\)—see if you can beat me!). Plot the actual ridership versus predicted ridership.

  8. How well do you think your model would predict ridership next week? Explain your reasoning in a few sentences.

Submitting HW

When you’ve successfully answered all the questions, knit your document to a PDF file. Look through it to make sure everything worked the way you expect it to. You will submit both your .Rmd and .pdf files to Schoology.