---
output: html_document
---
  
### Predictors

**Candidate predictors**
The predictors are determined using data recorded relative to the target cohort index date.  The settings `endDays` specifies the number of days relative to the target index that is the latest point in time for determining the covariates.  For example, an `endDays` of -1 means that no data recorded on index or after are used by the covariates (the covariates only use data recorded up to index-1 day).

```{r, echo=FALSE, results = 'asis'}

if(class(covariateSettings) == 'covariateSettings'){
  covariateSettings <- list(covariateSettings)
}

cat('\n There are ', length(covariateSettings), ' covariate settings. \n')

for(i in 1:length(covariateSettings)){
  
   cat('\n Covariate Setting', i, '\n')
  
  dataC <- data.frame(
    name = c(
      'function',
      names(lapply(covariateSettings[[i]], function(x) paste(x, collapse = '-', sep='-')))), 
    value = c(
      attr(covariateSettings[[i]],"fun"), 
      unlist(lapply(covariateSettings[[i]], function(x) paste(x, collapse = '-', sep='-'))
      ))
  )
  row.names(dataC) <- NULL

print(knitr::kable(x = dataC, caption = paste('covariate setting ', i)))
  cat('\n \n')
}
```

**Feature Engineering**
```{r, echo=FALSE, results = 'asis'}

if(class(featureEngineeringSettings) == 'featureEngineeringSettings'){
  featureEngineeringSettings <- list(featureEngineeringSettings)
}

if(!is.null(attr(featureEngineeringSettings[[1]],"fun"))){
  if(attr(featureEngineeringSettings[[1]],"fun") != 'sameData'){
  
    cat('\n There are ', length(featureEngineeringSettings), ' feature engineering settings. \n')

    for(i in 1:length(featureEngineeringSettings)){
  
      cat('\n The function ', attr(featureEngineeringSettings[[i]],"fun"), ' with inputs: \n')

      feData <- data.frame(
        name = names(featureEngineeringSettings), 
        value = unlist(lapply(featureEngineeringSettings, function(x) paste(x, sep = '', collapse='-')))
        )
  
      print(knitr::kable(x = feData , caption = paste('feature engineering setting ', i)))
      cat('\n \n')
  
    }

  } else{
  cat('\n None \n')  
  }
} else{
  cat('\n None \n')  
}


```

**Pre-processing**

The following pre-processing were applied:


```{r, echo=FALSE, results = 'asis'}

if(preprocessSettings$normalize){
  cat('\n - The data were normalized using the formula: value/maxValue . \n')
}

if(preprocessSettings$minFraction > 0){
  cat('\n - Candidate predictors occuring in less than ', preprocessSettings$minFraction*100,'\\% of patients in the target population were removed. \n')
}

if(preprocessSettings$removeRedundancy){
  cat('\n - Candidate predictors that were redundant (completely correlated with another predictor) were removed.  When two predictors are completely correlated, the most common predictor is removed.  For example, if 60\\% of the target population were male and 40\\% were female, then the male gender predictor would be removed since it is redundant and more common. \n')
}

```

