# Post-Hoc Analysis

## :rocket: The Retro-Analysis Module

Sometimes we might want to rerun analysis after a Session, Trial or Experiment has completed. For instance, we added new derived metrics or new ways to plotting the graphs. This quick tutorial will show us a command to do so.

Since all the analysis data are generated by the [analysis module](https://github.com/kengz/SLM-Lab/blob/master/slm_lab/experiment/analysis.py), we can simply rerun it on the Session, Trial or Experiment. This is handled by the [retro\_analysis module](https://github.com/kengz/SLM-Lab/blob/master/slm_lab/experiment/retro_analysis.py).

Let's supposes our data is saved to `data/ppo_lunar_2019_11_30_002958` and we wish to run retro\_analysis on it. Use the following command:

```bash
python -c 'import sys; from slm_lab.experiment import retro_analysis; retro_analysis.retro_analyze("data/ppo_lunar_2019_11_30_002958")'
```

When invoked, the retro\_analysis module will load the data saved at the end of Session, Trial and Experiment, then call the analysis module methods on them. When completed, the new derived data files will overwrite their older counterparts.

{% hint style="success" %}
The retro\_analysis module is safe and free from side-effects – it only overwrites data that is derived, so there is no risk of destroying the data that needs a full rerun to recollect.
{% endhint %}
