---
title: "Statistics 652 - Midterm"
author: "Prof. Eric A. Suess"
date: today
format: 
  html:
    embed-resources: true
toc: true
---

**Instructions:**  Do your best to develop the models using the R tidymodels package.  You can use the GitHub Copilot code completion to work on the code.  Please note the there is a subdirectory in the R Project that contains R tidymodels code for all of the models you are required to build.  You can use that code as a starting point for your work.  I would suggest updating the code to use the new tidymodels workflow() function.

# Midterm

### Question 1

Clearly state the 5 steps for applying Machine Learning to a problem.

### **Answer:**

- Step 1:

- Step 2:

- Step 3:

- Step 4:

- Step 5:


### Question 2

For the [titanic](https://www.kaggle.com/c/titanic/data) data set try the following machine learning classification algorithms.

Use the training and test datasets from the **titanic** R package.

You should note that the *titanic_train* has the *Survived* variable and the *titanic_test* does not.  So to select your best model you need to use the *titanic_train* dataset to train and test your models.  So that means you will need to select a training dataset from *titanic_train* and select a testing dataset (this would be a validation dataset) from *titanic_train* to evaluate the models you try.

I have not demonstrated the use of cross-validation, once you are comfortable running all of the models see if you can figure out how to use cross-validation to pick the best model.

Once you have picked the best model you should do the following:

1. Re-run your chosen model on the full *titanic_train* dataset.
2. Then produce predictions for the *titanic_test* dataset.  This is what you would submit in a .csv to [Kaggle](https://www.kaggle.com/) in a competition.

Build **classification models** for the *Survived* variable. Pick an appropriate model scoring function, i.e. metric, and determine which model is the best. I would suggest making a confusion matrix and computing the accuracy or kappa. 

0. Null Model
1. kNN (the sample code given did not scale or normalize, if you use this model you need to do that.)
2. Boosted C5.0 
3. Random Forest
4. Logistic Regression using regularization
5. Naive Bayes

Extra Credit:

Make one plot containing all of the ROC curves for the algorithms trained.

# Data

```{r, eval = FALSE}
library(titanic)

data(titanic_train)
data(titanic_test)

head(titanic_train)
head(titanic_test)
```


# Model 0 Null Model

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

# Model 1 kNN

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

# Model 2 Boosted C5.0

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

# Model 3 Random Forest

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

# Model 4 Logistic Regression using regularization

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

# Model 5 Naive Bayes

### **Answer:**

<<< REMOVE Summarize your answer to the question here.  All code and comments should be below and your written answer above. REMOVE >>>

### **Code and Comments:**

```{r}

```

