-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated data_container.ipynb to reflect changes to pm.Data containers in pymc v5.16 #676
updated data_container.ipynb to reflect changes to pm.Data containers in pymc v5.16 #676
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@@ -58,19 +58,17 @@ This notebook will illustrate each of these benefits in turn, and show you the b | |||
|
|||
+++ | |||
|
|||
## Types of Data Containers | |||
## Current and past states of Data Containers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this whole section can be deleted and maybe replaced with an info box of your last comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I will make the change.
@@ -99,20 +97,20 @@ Furthermore, inside `idata`, PyMC has automatically saved the observed (endogeno | |||
idata.observed_data | |||
``` | |||
|
|||
In this next model, we create a `pm.ConstantData` containers to hold the observations, and pass this container to the `observed`. We also make a `pm.ConstantData` container to hold the `x` data: | |||
In this next model, we create a `pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a `pm.Data` container to hold the `x` data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this next model, we create a `pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a `pm.Data` container to hold the `x` data: | |
In this next model, we create a {class}`pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a {class}`pm.Data` container to hold the `x` data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change everywhere we use pm.Data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for clarifying that for me. I was not sure if the {class}
was only supposed to appear the first time we introduce the class. I will make the changes to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be one of {class}`pymc.Data`
(will render pymc.Data as link) or {class}`~pymc.Data`
(will render only Data as link). Sphinx doesn't know about pm
. I prefer the 1st one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twiecki @OriolAbril Would it be preferable to change all pm.Data
to {class}pymc.Data
or is it preferred that I go back to keeping it as pm.Data
without {class}
? At the start of the notebook, there is a reference to {class}pymc.Data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer pymc.Data
as a link, but I don't really care much either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I went ahead and changed it so that it is {class} pymc.Data
everywhere in the markdown text.
beta = pm.Normal("beta") | ||
mu = pm.Deterministic("mu", beta * x_data) | ||
sigma = pm.Exponential("sigma", 1) | ||
obs = pm.Normal("obs", mu=mu, sigma=sigma, observed=y_data) | ||
idata = pm.sample(random_seed=RANDOM_SEED) | ||
``` | ||
|
||
Because we used a `pm.ConstantData` container, the data now appears on our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph. | ||
Because we used a `pm.Data` container, the data now appears on our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we used a `pm.Data` container, the data now appears on our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph. | |
Because we used a `pm.Data` container, the data now appears in our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I missed that. Thank you, for catching it. I will fix it.
|
||
In past versions of PyMC, the only data container was `pm.Data`. This container is still available for backwards compatability, but the current best practice is to use either `pm.MutableData` or `pm.ConstantData`. | ||
:::{important} | ||
In past versions of PyMC, there were two types of data containers {func}`pymc.MutableData` and {func}`pymc.ConstantData` these are now deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In past versions of PyMC, there were two types of data containers {func}`pymc.MutableData` and {func}`pymc.ConstantData` these are now deprecated. | |
In past versions of PyMC, there were two types of data containers {func}`pymc.MutableData` and {func}`pymc.ConstantData`. These have been deprecated as all data containers are mutable now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, for the review @twiecki. I have made the change that you have suggested.
Thanks @Dekermanjian! |
related to #659
The data container notebook is out of date. It uses the deprecated
pm.ConstantData
andpm.MutableData
methods.The changes I made were:
pm.Data
but keeping a section that refers to the deprecatedpm.MutableData
andpm.ConstantData
in case a new user sees that in example code elsewhere.pm.ConstantData
andpm.MutableData
withpm.Data
in the code and in the markdown textcoords
withcoords
to reflect that all coordinates are now mutable and explain that fact in the preceding markdown text📚 Documentation preview 📚: https://pymc-examples--676.org.readthedocs.build/en/676/