Support units of measurement in PyMC #7812
drbenvincent
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Code examples? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Many statistical models (especially in scientific, engineering, and health applications) are built around physical quantities that carry units (e.g., meters, seconds, kilograms). Currently, PyMC treats all variables as unitless, which may lead to misinterpretations or errors when combining data with different units or when interpreting model parameters.
Adding optional support for units would:
This could be implemented via integration with existing Python libraries like pint
In general, the idea would be to optionally specify the units. Initially it might be required to specify the units of all data and parameters and pymc could help with unit checking to avoid errors.
This would be useful as we could check unit consistency, but also make errors less likely (e.g. expressing slope priors in the wrong units).
It could be very fun to explore unit inference. For example, if you specify the units of data but not the parameters, if we are regressing
weight ~ age
where weight is in kg and age is in years, the model could infer that the slope is in units of kg/year and the intercept is in units of kg.I'll leave it there - this is an initial proposal which is intended to spark discussion.
Beta Was this translation helpful? Give feedback.
All reactions