# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://slm-lab.gitbook.io/slm-lab/v4.2.0/using-slm-lab/post-hoc-analysis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
