Closed jessegrabowski closed 11 months ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Just saw #527, I didn't even know this feature existed. I'll update this notebook to use it in the final example.
Thanks! This is great, we get questions about this quite often
I refactored the last baby weight example to:
I think (2) is important, since it's not really a documented feature anywhere yet.
View / edit / reply to this conversation on ReviewNB
twiecki commented on 2023-07-12T09:26:25Z ----------------------------------------------------------------
Should we just rename this to Using Data containers?
jessegrabowski commented on 2023-07-12T09:46:55Z ----------------------------------------------------------------
I like that better, since users don't need to know what a "shared variable" is to use the data containers API
View / edit / reply to this conversation on ReviewNB
twiecki commented on 2023-07-12T09:26:26Z ----------------------------------------------------------------
*allow you to
Maybe also mention why anyone would want to use ConstantData (performance).
Also, I think that pm.Data also allows specification of dims, no? The only reason we have Data, MutableData, and ConstantData is historical and I think we should say that best practice is to use MutableData and ConstantData and only mention Data as a side-note.
jessegrabowski commented on 2023-07-12T09:44:57Z ----------------------------------------------------------------
I was thinking it would be nice to change one of the examples to use ConstantData, so that there's one usage for both. Maybe the first example. Then we could change around some headings (to point out which container is being used in which section, and why)?
A short passage at the beginning could be added, like "In past versions of PyMC, data was added to a model using pm.Data
. While this is still possible for backwards-comparability reasons, the current best practice is to use either pm.MutableData
or pm.ConstantData
,depending on your needs. This notebook will demonstrate how each of these data containers are used, and when they are appropriate".
twiecki commented on 2023-07-13T10:20:53Z ----------------------------------------------------------------
Yes, I think that's perfect.
jessegrabowski commented on 2023-07-13T10:59:44Z ----------------------------------------------------------------
I tried adding some details about each of the containers and give an example for each, let me know if it falls short of the mark.
View / edit / reply to this conversation on ReviewNB
twiecki commented on 2023-07-12T09:26:27Z ----------------------------------------------------------------
size is internal API, either use shape, or, better yet, also a dummy-dim.
jessegrabowski commented on 2023-07-12T09:51:08Z ----------------------------------------------------------------
What do you mean by a dummy dim?
twiecki commented on 2023-07-13T10:20:20Z ----------------------------------------------------------------
Oh, I see what you're doing here now. I think it should just be shape
though.
I was thinking it would be nice to change one of the examples to use ConstantData, so that there's one usage for both. Maybe the first example. Then we could change around some headings (to point out which container is being used in which section, and why)?
A short passage at the beginning could be added, like "In past versions of PyMC, data was added to a model using pm.Data
. While this is still possible for backwards-comparability reasons, the current best practice is to use either pm.MutableData
or pm.ConstantData
,depending on your needs. This notebook will demonstrate how each of these data containers are used, and when they are appropriate".
View entire conversation on ReviewNB
I like that better, since users don't need to know what a "shared variable" is to use the data containers API
View entire conversation on ReviewNB
Oh, I see what you're doing here now. I think it should just be shape
though.
View entire conversation on ReviewNB
I tried adding some details about each of the containers and give an example for each, let me know if it falls short of the mark.
View entire conversation on ReviewNB
Update
how_to/data_container
to PyMC 5.6Related to #333
The data container notebook is out of date. It uses PyMC3, and uses several APIs that are no longer needed/suggested/supported. Most prominent is using
pm.Data
instead of specifyingpm.MutableData
, but other small updates include:return_inferencedata=True
frompm.sample
az.from_pymc
to add apredictions
group; users should instead use thepredictions=True
flag inpm.sample_posterior_predictive
idata
to include aposterior_predictive
group; users should passextend_idata=True
insteadI also added a small explanation about the difference between
pm.ConstantData
and how to set mutablecoords
usingmodel.add_coord
. There might be a better way to do that last one.:books: Documentation preview :books:: https://pymc-examples--559.org.readthedocs.build/en/559/