# How to get the labels for the predictive distribution?

**URL:** https://discourse.pymc.io/t/how-to-get-the-labels-for-the-predictive-distribution/9502
**Category:** version agnostic
**Tags:** bambi
**Created:** [May 26, 2022, 9:33pm UTC](https://discourse.pymc.io/t/how-to-get-the-labels-for-the-predictive-distribution/9502 "2022-05-26T21:33:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mr\_penguin](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@mr\_penguin](https://discourse.pymc.io/u/mr_penguin)
#### Post date: [May 26, 2022, 9:33pm UTC](https://discourse.pymc.io/t/how-to-get-the-labels-for-the-predictive-distribution/9502/1 "2022-05-26T21:33:17Z")

</div>

I have a model in bambi, and I can get the predictive distribution for new data in this model into a dataframe by running model.predict(…).to\_dataframe(). But when I do, I get a long list of responses for each draw and each observation. Is there a way to list the observation, draw, and chain that generated each prediction?

---

<div class="post-metadata">

### Author: ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)
#### Post date: [May 27, 2022, 5:07am UTC](https://discourse.pymc.io/t/how-to-get-the-labels-for-the-predictive-distribution/9502/2 "2022-05-27T05:07:12Z")

</div>

I am not super familiar with bambi, but I think the call to `predict()` returns a standard `arviz.InferenceData` object and you are probably only interested in the `posterior_predictive` group in that object. So instead of converting the entire object to a dataframe, you probably just want that group. Given that you are converting the return value of `predict()`, I assumed you have set the `inplace` argument to `False`:

```python
ppc = model.predict(idata, kind='pps', inplace=False)['posterior_predictive']
# convert to pandas dataframe if you like
print(ppc.to_dataframe())

```

Given the defaults, I think the idea is to use the inferenceData object as cumulative storage:

```python
idata = model.fit()
model.predict(idata, kind='pps')
print(idata['posterior_predictive'].to_dataframe())

```

---

<div class="post-metadata">

### Author: ![tcapretto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tcapretto/32/4902_2.png) [@tcapretto](https://discourse.pymc.io/u/tcapretto)
#### Post date: [May 31, 2022, 2:11am UTC](https://discourse.pymc.io/t/how-to-get-the-labels-for-the-predictive-distribution/9502/3 "2022-05-31T02:11:29Z")

</div>

@cluhmann points in the right direction.

`Model.predict()` modifies or creates an `arviz.InferenceData` object. When you use `kind="mean"` it adds a new variable to the `.posterior` group (the name of the new variable is the name of the response with `_mean` appended). If you use `kind="pps"` it obtains posterior predictive samples, and it is added to the `.posterior_predictive` group.
