Skip to content

Variable selection for pm.model_to_graphviz #5527

Closed
@michaelosthege

Description

@michaelosthege

Description of your problem

I have a big big model and would like to make pm.model_to_graphviz plots of only some of the variables inside.
For example after adding gp.conditionals and then only wanting to plot the nodes my new variable depends on.

My model also includes some ConstantData variables I use to store indexing information.
They aren't relevant for model understanding and I'd like to hide them.

Proposal

The pm.model_to_graphviz function could take additional kwargs to customize the plot:

  • var_names (or vars?) to plot only certain variables and their dependencies
  • show_disconnected_data: bool to hide ConstantData/MutableData nodes that don't contribute to (selected) model variables

Implementation

Variable selection should be straightforward since it's already in the constructor, just not accessible via a kwarg:

pymc/pymc/model_graph.py

Lines 33 to 36 in a3bab7d

def __init__(self, model):
self.model = model
self.var_names = get_default_varnames(self.model.named_vars, include_transformed=False)
self.var_list = self.model.named_vars.values()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions