# Stochastic labels

**URL:** <https://discourse.pymc.io/t/stochastic-labels/5820>\
**Category:** Questions\
**Created:** [September 21, 2020, 4:10pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820 "2020-09-21T16:10:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ma\_macneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ma_macneil/32/2238_2.png) [@ma\_macneil](https://discourse.pymc.io/u/ma_macneil)\
**Post date:** [September 21, 2020, 4:10pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/1 "2020-09-21T16:10:01Z")

</div>

Hi All,

I haven’t visited this topic in quite a while, so apologies if it has been dealt with (I couldn’t find it here) but one small feature that would help this user is to allow lists of variable names to be passed to a stochastic node, e.g.

labelx = [‘gold’, ‘blue’, ‘black’]

beta = pm.Normal(labelx, 0, 1, shape=len(labelx))

I’m sure it requires more than I know to add, but it would save some post-sampling hassle.

Thx!  
A

---

<div class="post-metadata">

**Author:** ![sammosummo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/sammosummo/32/96_2.png) [@sammosummo](https://discourse.pymc.io/u/sammosummo)\
**Post date:** [September 21, 2020, 7:44pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/2 "2020-09-21T19:44:42Z")

</div>

I think the kwarg `dims` does exactly what you want.

---

<div class="post-metadata">

**Author:** ![ma\_macneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ma_macneil/32/2238_2.png) [@ma\_macneil](https://discourse.pymc.io/u/ma_macneil)\
**Post date:** [September 21, 2020, 11:20pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/3 "2020-09-21T23:20:11Z")

</div>

`dims` is the dimension if I understand, rather than the labelling, non?

---

<div class="post-metadata">

**Author:** ![sammosummo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/sammosummo/32/96_2.png) [@sammosummo](https://discourse.pymc.io/u/sammosummo)\
**Post date:** [September 22, 2020, 12:16am UTC](https://discourse.pymc.io/t/stochastic-labels/5820/4 "2020-09-22T00:16:27Z")

</div>

It labels them as well. So if you used labelx as your sims and plotted the posteriors, gold, blue etc. would appear as subplot titles.

---

<div class="post-metadata">

**Author:** ![ma\_macneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ma_macneil/32/2238_2.png) [@ma\_macneil](https://discourse.pymc.io/u/ma_macneil)\
**Post date:** [September 22, 2020, 12:56am UTC](https://discourse.pymc.io/t/stochastic-labels/5820/5 "2020-09-22T00:56:12Z")

</div>

Ah ok – i’ll give that a try and report back,

Many thanks,  
A

---

<div class="post-metadata">

**Author:** ![ma\_macneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ma_macneil/32/2238_2.png) [@ma\_macneil](https://discourse.pymc.io/u/ma_macneil)\
**Post date:** [September 22, 2020, 12:10pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/6 "2020-09-22T12:10:13Z")

</div>

Digging in I can see how this is an arviz plotting soloution (currently I do this in pandas) but I suppose what I’m asking is why a list of labels couldn’t be added into a given stochastic node at instantiation, then passed on to the sampler, arviz etc. Would seem simpler to have it inherited from the start.

Thank much,  
A

---

<div class="post-metadata">

**Author:** ![sammosummo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/sammosummo/32/96_2.png) [@sammosummo](https://discourse.pymc.io/u/sammosummo)\
**Post date:** [September 24, 2020, 4:51pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/7 "2020-09-24T16:51:08Z")

</div>

> [@ma\_macneil](#):
>
> why a list of labels couldn’t be added into a given stochastic node at instantiation

I mean, that is exactly what `dims` is doing.

If you have your traces in arviz’s `InferenceData` format (which I strongly recommend) and poke around with it, you’ll find that the data are stored in `xarray` under the hood. This allows dimensions to be accessed in much the same way as columns or rows in a pandas DataFrame, or in place of axes in numpy arrays.

Really, `dims` a quite an interoperable approach. You can do a lot with it once you start digging.

**EDIT** : Just saw [this](https://discourse.pymc.io/t/pymc3-arviz-improve-your-workflow-with-labeled-coords-and-dims/5826)!

---

<div class="post-metadata">

**Author:** ![ma\_macneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ma_macneil/32/2238_2.png) [@ma\_macneil](https://discourse.pymc.io/u/ma_macneil)\
**Post date:** [September 24, 2020, 10:30pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/8 "2020-09-24T22:30:15Z")

</div>

Ah ok – I’ll take a look at that post, thanks very much for tracking it down.

---

<div class="post-metadata">

**Author:** ![mamacneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mamacneil/32/2831_2.png) [@mamacneil](https://discourse.pymc.io/u/mamacneil)\
**Post date:** [October 5, 2020, 4:11pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/9 "2020-10-05T16:11:01Z")

</div>

Thanks again for the blogpost on the arviz labels - one quesiton I have for the PyMC devs is if this could be added to the pm.summary() table output - small thing but could be of high utility to pass into this.

Thanks devs!  
A

---

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [October 5, 2020, 5:51pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/10 "2020-10-05T17:51:29Z")

</div>

Hi Aaron,  
PyMC’s plots and diagnostics are actually handled by [ArviZ](https://arviz-devs.github.io/arviz/). You can already use `dims` and `coords` in most functions, but not yet in `az.summary` – there is [work on that](https://github.com/arviz-devs/arviz/issues/1091) actually, but it’s quite complex. It will indeed be super useful once that’s out, but we’ll need a little more patience 😉  
Feel free to ask and contribute to this PR if you want BTW!  
Hope this helps 🖖

---

<div class="post-metadata">

**Author:** ![mamacneil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mamacneil/32/2831_2.png) [@mamacneil](https://discourse.pymc.io/u/mamacneil)\
**Post date:** [October 5, 2020, 9:02pm UTC](https://discourse.pymc.io/t/stochastic-labels/5820/11 "2020-10-05T21:02:27Z")

</div>

Thanks for the update and the great work on this - I’ve incorporated the plotting dims and coords already for tomorrow’s lecture. Will check in to see if I can contribute once I’m free of teaching in the New Year.  
Cheers!  
A
