pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Allow exclusion of variables and their descendants with ~ in `var_names`

Open larryshamalama opened this issue 3 years ago • 0 comments

Following the merge of #5527, it would be good to allow users to selectively exclude variables using ~ in var_names. For instance, given a full model:

with pm.Model() as pmodel2:
    a = pm.Normal("a")
    b = pm.Normal("b")
    c = pm.Normal("c", a * b)
    intermediate = pm.Deterministic("intermediate", a + b)
    pred = pm.Deterministic("pred", intermediate * 3)

    obs = pm.ConstantData("obs", 1.75)

    L = pm.Normal("L", mu=1 + 0.5 * pred, observed=obs)

display(pm.model_to_graphviz(pmodel2)) # Fig. 1
display(pm.model_to_graphviz(pmodel2, var_names=["~pred"])) # Fig. 2

which would yield the following images where, in Fig. 2, pred, L and obs are all removed.

Fig. 1 Fig. 2

larryshamalama avatar May 23 '22 19:05 larryshamalama