pymc.model.transform.conditioning.remove_value_transforms#

pymc.model.transform.conditioning.remove_value_transforms(model, vars=None)[source]#

Remove the value variables transforms in the model

Parameters:
modelModel
varsModel variables, optional

Model variables for which to remove transforms. Defaults to all transformed variables

Returns:
new_modelModel

Model with the removed transformed value variables

Examples

Extract untransformed space Hessian after finding transformed space MAP

import pymc as pm
from pymc.model.transform.conditioning import remove_value_transforms

with pm.Model() as transformed_m:
    p = pm.Uniform("p", 0, 1)
    w = pm.Binomial("w", n=9, p=p, observed=6)
    mean_q = pm.find_MAP()

with remove_value_transforms(transformed_m) as untransformed_m:
    new_p = untransformed_m["p"]
    std_q = ((1 / pm.find_hessian(mean_q, vars=[new_p])) ** 0.5)[0]
    print(f"  Mean, Standard deviation\np {mean_q['p']:.2}, {std_q[0]:.2}")

#   Mean, Standard deviation
# p 0.67, 0.16