Model#

class liesel.model.model.Model(nodes_and_vars, grow=True, copy=False)[source]#

Bases: object

A model with a static graph.

Parameters
  • nodes_and_vars (Iterable[Node | Var]) – The nodes and variables to include in the model.

  • grow (bool) – Whether a GraphBuilder should be used to grow the model (finding the recursive inputs of the nodes and variables), and to add the model nodes. (default: True)

  • copy (bool) – Whether the nodes and variables should be copied upon initialization. (default: False)

Methods

copy_nodes_and_vars()

Returns an unfrozen deep copy of the model nodes and variables.

groups()

Composes the groups defined in the model nodes and variables.

pop_nodes_and_vars()

Pops the nodes and variables out of this model.

set_seed(seed)

Splits and sets the seed / PRNG key.

update(*names)

Updates the target nodes and their recursive inputs if they are outdated.

Attributes

auto_update

Whether to update the model automatically if the value of a node is modified.

log_lik

The log-likelihood of the model.

log_prior

The log-prior of the model.

log_prob

The (unnormalized) log-probability / log-posterior of the model.

node_graph

The directed graph of the model nodes.

nodes

A mapping of the model nodes with their names as keys.

state

The state of the model as a dict of node names and states.

var_graph

The directed graph of the model variables.

vars

A mapping of the model variables with their names as keys.