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

Answer the following questions:

# Question 1

Read the paper, "Feature Selection with the Boruta Package" by Miron B. Kursa and Witold R. Rudnicki.  See the Final R Project subdirectory /Boruta for the pdf of the Journal of Statistical Software paper from 2010.

What are the important variables identified by the Boruta algorithm from the **Ozone** data?  Use the output of the provided code below.

**Answer:**


**Code:**



```{r}
library(pacman)
p_load(tidyverse, janitor, naniar, DataExplorer, Boruta, mlbench)
```

```{r}
data(Ozone)

head(Ozone)
```

Note that the target variable is V4 = Daily maximum one-hour-average ozone reading.

Convert V1, V2, and V3 to integers.

```{r}
Ozone <- Ozone %>% mutate(
  V1 = as.integer(V1),
  V2 = as.integer(V2),
  V3 = as.integer(V3)
)

head(Ozone)
```

```{r}
Ozone2 <- Ozone %>% clean_names()

head(Ozone2)
```

It is always a good idea to check for duplicate records/examples/rows in your dataset.

```{r}
get_dupes(Ozone2)
```

Start by investigating the missing values and completeness of the features in the data.  Note that the *age* variable contains some missing values.

```{r}
vis_miss(Ozone2)
gg_miss_var(Ozone2)
gg_miss_var(Ozone2, show_pct = TRUE)
```

Do not run this code when Rendering the .qmd file.

```{r eval = FALSE}
create_report(Ozone2, y = "v4", output_file = "report_Ozone.html", output_dir = getwd())
```

Drop V9 because it is missing more than 40% of its values.

```{r}
Ozone2 <- Ozone2 %>% select(-v9)

vis_miss(Ozone2)
gg_miss_var(Ozone2)
gg_miss_var(Ozone2, show_pct = TRUE)
```

```{r}
Ozone2 <- drop_na(Ozone2)

vis_miss(Ozone2)
gg_miss_var(Ozone2)
gg_miss_var(Ozone2, show_pct = TRUE)
```


```{r}
Boruta.Ozone <- Boruta(v4 ~ ., data = Ozone2, doTrace = 2, ntree = 500)
```

```{r}
Boruta.Ozone
```

```{r}
plot(Boruta.Ozone)
```


```{r}
Boruta.Short <- Boruta(v4 ~ ., data = Ozone2, maxRuns = 12)
```

```{r}
Boruta.Short 
```

```{r}
plot(Boruta.Short)
```

```{r}
TentativeRoughFix(Boruta.Short)
```

```{r}
getConfirmedFormula(Boruta.Ozone)
```

```{r}
attStats(Boruta.Ozone)
```

```{r}
plotImpHistory(Boruta.Ozone)
```


# Question 2

What are the important variables identified by the Boruta algorithm from the **titanic training** data?  Provide code below to run the Boruta algorithm on the **titanic_train** data.

**Answer:**


**Code:**

```{r}
library(titanic)
data(titanic_train)
```

# Question 3:

a) Define clear what the metric kappa measures.

**Answer:**

b) Use an AI tool you are comfortable with, [Google AI Studio](https://aistudio.google.com/prompts/new_chat), [ChatGPT](https://chatgpt.com/), [Mistral](https://mistral.ai/), [Microsoft Colab](https://copilot.microsoft.com/), or another to prepare a response to the prompt provided in part a).  Comment on the similarity of your answer with that provided by an AI tool.

**Answer:**


# Question 4:

Using your selected AI tool, upload or share the [steps01.docx](http://cox.csueastbay.edu/~esuess/statistics652/_presentations/Five_Steps/steps01.docx) with the AI.

a) Write a prompt to summarize and explain the ideas presented in the document.  Ask for further details be added to the summary for each step.  Ask for example R and Python code using the tidyverse and tidymodels package.


**Answer:** prompt



**Answer:** summary of the AI generated summary of the *steps01.docx*.


