```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)
library(tidymodels)
```

## Read in the `train.csv` data. Please feel free to use `sample_frac()` if you find that the data file is too large for your machine.

```{r, data}


```


## 1. Initial Split

Set a seed and split the data into a training set and a testing set as two named objects. 

```{r, initial_split}


```

## 2. Resample

Set a seed and use 10-fold cross-validation to resample the traning data.

```{r, resample}


```

## 3. Preprocess

Complete the code maze below by filling in the blanks (____) to create a recipe object that includes:
* a formula model with `score` predicted by 4 predictors
* be sure there are no missing data in your predictors (try `step_naomit()`)
* center and scale all numeric predictors
* dummy code all nominal predictors

```{r, preprocess}

lasso4_rec <- 
  recipe(
    formula = ____, 
    data = ____ #use your training set here
  ) %>%
  step_naomit(everything(), skip = TRUE) %>% 
  step_string2factor() %>%  #may not need, depending on your formula
  step_dummy() %>% #may not need, depending on your formula
  step_normalize() #may not need, depending on your formula

```

## 4. Parsnip model

Create a `{parsnip}` lasso model where the penalty hyperparameter is set to be tuned.

```{r, lasso}



```

## 5. Fit a tuned lasso model

Complete the code maze below to fit a tuned lasso model.

```{r, lasso_fit_1}

lasso_grid <- grid_regular(penalty())

lasso4_fit_1 <- tune_grid(
  ____,
  preprocessor = ____,
  resamples = ____,
  grid = lasso_grid,
  control = tune::control_resamples(verbose = TRUE,
                                    save_pred = TRUE)
)

```

### Question A
  + How many models were fit to each fold of `lasso4_fit_1`? (Please provide a numeric answer, *and* use code to corroborate your answer.)
  
```{r}

```

  + Use code to list the different values of `penalty()` that were used.

```{r}


```

## 6. Fit another tuned lasso model

Use your code from (5) above to complete the code maze below to fit a second tuned lasso model, using the same `parsnip` model, `recipe`, and resampled object you used before.

```{r, lasso_fit_2}

lasso4_fit_2 <- tune_grid(
  ____,
  preprocessor = ____,
  resamples = ____,
  control = tune::control_resamples(verbose = TRUE,
                                    save_pred = TRUE)
)

```

### Question B

  + How many models were fit to each fold of `lasso4_fit_2`? (Please provide a numeric answer, *and* use code to corroborate your answer.)

```{r}


```

  + If this is different than the number of models of `lasso4_fit_1`, please explain why.

  + Use code to list the different values of `penalty()` that were used for *lasso4_fit_2*.

```{r}


```

## 7. Complete the necessary steps to create and fit a tuned lasso model that has seven or more predictors (use any tuning grid you like). Note that you will need to create a new recipe as well.

```{r, lasso8}




```

## 8. Compare the metrics from the best lasso model with 4 predictors to the best lasso model with 7+ predicors. Which is best?

```{r}

```

## 9. Fit a tuned elastic net model with the same predictors from (7). 
  + Create a new `{parsnip}` elastic net model
  + Use the same recipe from (7) above
  + Create and apply a regular grid for the elastic net model
  + Compare the metrics from the elastic net model to the best lasso model from (8). Which would you choose for your final model? What are the best hyperparameters for that model?

```{r}


```


