Model#

class liesel.liesel.model.Model(nodes=None, groups=None)[source]#

Bases: object

A probabilistic graphical model.

A model is defined by the input-output relations between a number of Node objects. This class provides methods to compute the log-probability of a model and to update its nodes efficiently.

Warning

This class does not check for missing inputs or groups that are not fully contained in a model. Use the ModelBuilder to set up a model in a safe way.

Methods

empty_copy()

Returns a deep copy of the model with an empty state.

get_nodes_by_class(cls)

Returns the nodes of the provided class from the model.

get_nodes_by_regex(regex)

Returns the nodes with matching names from the model.

jaxify()

Enables JAX NumPy for all nodes in the model.

transform_parameter(name, bijector)

Returns a deep copy of the model with the transformed parameter.

unjaxify()

Disables JAX NumPy for all nodes in the model.

update()

Updates all outdated nodes in the model.

Attributes

jaxified

Whether JAX NumPy is enabled for all nodes in the model.

log_prob

Returns the log-probability of the model.

state

Returns the state of the model.

nodes

A dictionary of the nodes in the model with their names as keys.

groups

A dictionary of the nodes groups in the model with their names as keys.

graph

The graph of the input-output relations between the nodes in the model.

sorted_nodes

A list of the nodes in the model in a topological order.