Random generation of Bayesian network
Creates a random BN using the (forced) keyword parameters. |
- class pyagrum.BNGenerator
BNGenerator is used to easily generate Bayesian networks.
- BNGenerator() -> BNGenerator
default constructor
Scientific notes
BNGenerator draws the DAG of a random Bayesian network with the mixed Markov chain (PMMixed) of
[1], on the connected DAGs with n_nodes nodes and at most n_arcs arcs (pyAgrum bounds the
number of arcs, not the induced width). The chain combines the moves of [2]: add or remove an arc
(a removal must keep the graph connected, an addition must keep it acyclic) and, for polytrees, add and remove (an
arc is added between two nodes and the arc of the path between them that would close a loop is removed), with the
jump of [1]: from a polytree, an arc is added; from a multiconnected graph, an arc is removed.
pyAgrum starts from a random tree on which n_nodes/2 arc reversals are applied, then runs 5000 steps. From a
polytree, a step uses add or remove with probability \(p = 0.3\), add and remove with probability
\(q = 0.4\), and a jump otherwise; from a multiconnected graph, it uses add or remove with probability
\(p + q\) (a step back to a polytree being then accepted with probability \(p/(p+q)\)), and a jump otherwise.
A change that exceeds n_arcs is rejected: the result has n_arcs arcs or slightly fewer for a sparse graph,
often clearly fewer for a dense one.
Each variable gets a domain size drawn uniformly between 2 and n_modmax. As in [2], each
distribution of a CPT (one per configuration of the parents) is drawn uniformly on the probability simplex, i.e. from a
Dirichlet distribution of parameter 1, by the sorted spacings of uniform draws.
Methods
Generate a new Bayesian network. |