---
title: "Session Report - Feature Importance"
output: html_document
params:
  session_info: NA ,
  feature_vars: NA,
  dependent_var: NA,
  groups: NA,
  fi_model: NA,
  fi_method: NA,
  folds_n: NA,
  repeats_n: NA,
  fi_output: NA,
  fi_plot: NA,
  warning_data: NA,
  warning_data_n: NA,
  na_omit : NA,
  na_n: NA
---
```{r setup, include=FALSE} 
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```

```{r, echo=FALSE}
htmltools::img(
  src = "tRigon_logo.png",
  alt = "logo",
  style = "position:absolute; top:0px; right:135px; height: 80px"
)
```
---

```{r, echo = FALSE}
params$session_info
```

features:
```{r, echo = FALSE}
params$feature_vars
```

dependent variable:
```{r, echo = FALSE}
params$dependent_var
```

groups / levels of dependent variable:
```{r, echo = FALSE}
if (params$fi_method == "Classification") {
  print(params$groups)
  if (params$na_omit == TRUE) {
    print(paste0("Warning: dependent variable contains NAs. ", params$na_n, " values excluded."))
  }
} else if (params$fi_method == "Regression") {
  print(paste0("numeric variable for regression: ", params$dependent_var))
  if (params$na_omit == TRUE) {
    print(paste0("Warning: dependent variable contains NAs. ", params$na_n, " values excluded."))
  }
}
``` 

feature importance method:
```{r, echo = FALSE}
if (params$fi_method == "Classification") { # classification
  if (params$fi_model == "recursive feature elimination") {
    print(paste0("recursive feature elimination (RFE) with ", params$folds_n, "-fold cross-validation and ", params$repeats_n, " repeats for classification of groups of the dependent variable. Data is distributed in a random 80/20 split for training and testing."))
  } else if (params$fi_model == "random forest") {
    print("random forest model for classification of the dependent variable.")
  }
} else if (params$fi_method == "Regression") { # Regression
  if (params$fi_model == "recursive feature elimination") {
    print(paste0("recursive feature elimination (RFE) with ", params$folds_n, "-fold cross-validation and ", params$repeats_n, " repeats for regression of the dependent variable. Data is distributed in a random 80/20 split for training and testing."))
  } else if (params$fi_model == "random forest") {
    print("random forest model for regression of the dependent variable.")
  }
}
```      

feature imbalance:
```{r, echo = FALSE}
if (params$warning_data) {
  print(paste0("Warning: input vectors of unequal length - only complete rows can be analysed for feature importance. ", params$warning_data_n, " rows with missing data excluded."))
} else {
  print("no imbalance in feature vector data reported.")
}
```

feature importance output:
```{r, echo = FALSE}
params$fi_output
```

feature importance plot:
<br/>
```{r dev='png', echo = FALSE}
plot(params$fi_plot)
```
