> For the complete documentation index, see [llms.txt](https://slm-lab.gitbook.io/slm-lab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://slm-lab.gitbook.io/slm-lab/master/using-slm-lab/post-hoc-analysis.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://slm-lab.gitbook.io/slm-lab/master/using-slm-lab/post-hoc-analysis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
