-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Consistent API for choosing model RVs / value vars #4846
Comments
Transformed variables are not a type of variable in the same sense that random variables and their value variables are; instead, they're value variables without explicit random variables. This is due to the old design of PyMC3, which exposes transformed variables at the user-level and makes them an explicit part of the API.
In general, it would probably be better to have the user only ever deal with random variables, and transforms should only ever be used internally.
What do you mean by "Defining everything in terms of value vars"?
To which user-level interactions with value variables are you referring? We would need to start enumerating those in order to determine which could/should be improved. One difficulty with that is determining what we would consider a user-level function, method, member, etc. Not everything exposed by classes like |
I agree. I gave 3 examples that I had in mind mostly because they were mentioned in recent user issues or I had to work with the internals (so it's pretty much ad-hoc):
I am sure there are others, perhaps in the more specialized modules |
The examples you originally gave were very specific to Regardless, yes, I think we should make most/all user-level interactions work in terms of the random variables—and preferably the actual |
The API ambiguity is manifest in all / most user facing methods that accept a list of variables (sometimes just the names), and whose docstrings usually reads something like ”input: list of model variables” This is separate from the |
Not sure if we're on the same page here: The existing API has this signature: |
We have these three types of variables: RandomVariables --- Value vars --- Transformed value vars
model["x"]
returns thex
RVmodel["y"]
returns they
RVmodel["y_log__"]
returns they
transformed value var.model.rvs_to_values[model["x"]]
returns thex
value varmodel.rvs_to_values[model["y"]]
returns they
transformed value varThe automatic transforms were always a source of confusion, and I am afraid the new changes will make things a bit more confusing still. We should try to be consistent in what is expected as input in PyMC sampling methods. e.g., when:
SMC
and allowprior_predictive_sampling
to return transformed values #4769)Proposal
I suggest that calling
model["varname"]
should always return the corresponding RV. All PyMC3 functions that need a list of variables as inputs should expect an RV and obtain the respective (transformed) value vars if needed. In line with this:model["y_log__"]
should fail.y
should be expected and automatically transformed toy_log__
if neededstep = pm.Metropolis([model["x"], model["y"]])
would work.Defining everything in terms of value vars makes less sense to me. For example they are not used in prior/predictive sampling. Users are also less likely to understand what they mean/ do.
The current approach makes even less sense, and results in a lot of duck typing / guessing on the backend to figure out what the user is trying to select.
The text was updated successfully, but these errors were encountered: