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
1 Like
I think the kwarg dims
does exactly what you want.
1 Like
dims
is the dimension if I understand, rather than the labelling, non?
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.
1 Like
Ah ok – i’ll give that a try and report back,
Many thanks,
A
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
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!
1 Like
Ah ok – I’ll take a look at that post, thanks very much for tracking it down.
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
Hi Aaron,
PyMC’s plots and diagnostics are actually handled by ArviZ. You can already use dims
and coords
in most functions, but not yet in az.summary
– there is work on that 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
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
1 Like