# Deep Learning

![](https://2045057293-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M32ms-dWLPjFImgSINF%2F-MiAALWOyLZh0qLKj-LU%2F-MiIZOWMPSomumlWCYWM%2Fimage.png?alt=media\&token=4afe599c-caeb-4106-87c5-0a4f3cf39b05)

### Used For

* Assess the performance of a deep neural network (implemented here as a multi-layer perceptron) on the OTU data in predicting a categorical or numerical variable
* Examples:
  * Predict patient outcome or sampling region based on the lung microbiome composition from COPD patients
  * Predict hospital length-of-stay based on the nasopharyngeal microbiome composition from ICU patients

{% hint style="info" %}
Use deep neural networks (DNN) with caution. DNNs are typically best when there are thousands of examples for each categorical class. DNNs are also prone to overfitting - dropout layers can help reduce overfitting.
{% endhint %}

### Feature Selection Parameters

#### Taxonomic Level

The taxonomic level to aggregate the OTUs at. The OTUs will be grouped together (by summing the OTU values) at the selected taxonomic level before the analysis is applied.

#### Experimental Variable

The categorical or numeric variable that the model should predict.&#x20;

#### Freeze Training Set Between Changes

If set to yes, ensures that the same samples are used as the training set every the model is retrained. This useful to keep the test set untouched.&#x20;

#### Training Proportion

Define the proportion of the data that should be randomly picked to form a training dataset.&#x20;

#### Training Validation Proportion

Define the proportion of the training data that should be randomly picked to form a validation dataset.&#x20;

#### Training Epochs

The maximum number of passes through the training data.&#x20;

#### Problem Type

Whether the DNN will be trained as a classifier (categorical) or a regressor (numeric). This value is automatically set based on the variable selected in the "Experimental Variable" section.

#### Measure

Assess the model by either using the accuracy or cross-entropy loss for classification problems or mean absolute error or mean squared error for regression problems.&#x20;

This affects both the training/validation test plot and the final test accuracy or loss.&#x20;

#### Layers

![](https://2045057293-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M32ms-dWLPjFImgSINF%2F-M3UugICbF92rPxm26bQ%2F-M3V1mgxEB_fUlOpGp1r%2Fimage.png?alt=media\&token=4331f847-3571-49ed-b8bf-fe730febca1d)

Customize and build your own deep neural network by setting the number and type of layers you want to use:

* **Dense Layer**: The neurons are fully-connected to the neurons of the next layer.&#x20;
* [**Dropout Layer**](https://en.wikipedia.org/wiki/Dropout_\(neural_networks\)): The percentage of connections to randomly drop between the current layer and the next layer. Dropout reduces overfitting by preventing co-adaptions between neurons.

### Result Interpretation

* The figure shows you the loss over training epochs. The loss should decrease as the number of epochs increase. Tips:
  * If the loss fluctuates, try decreasing the learning rate.
  * If the loss doesn't plateau, try increasing the learning rate.
  * If the training and validation losses diverge, you have overfitting. In this case, try adding a dropout layer or decreasing the number of layers in the model.
  * If the losses do not decrease, try increasing the number of layers or increasing the number of units in each layer.
* Assess the predictive performance of your model using the test AUC (area under the [ROC curve](https://en.wikipedia.org/wiki/Receiver_operating_characteristic) shown).\
  &#xNAN;_&#x4E;ote: Whenever possible, it is still recommended to validate a trained model against an independent dataset (one that is collected outside of your study)._
* Tune your model for better performance by looking only at the validation AUC. Tuning refers to changing the configurable parameters to try to achieve a better performance for your dataset. \
  &#xNAN;_&#x49;t is important to not tune against the test AUC to ensure you don't overfit your model to the test set._
* The AUC tells you the probability that a randomly sampled positive patient will have a higher predicted score for the positive class than the negative class. The AUC will be shown in a "one-vs-all" format.

### Interactive Elements

* Hover over the training/validation curve&#x20;

### Additional Features

* **Save Snapshot**: Save the results to the experiment notebook
* **Download**: Downloads the results as a CSV file
* **Share**: Creates a shareable link that allows you to share the results with others
