Manuscript Offprint
arXiv:2610.16902Neural Bayesian Networks for Modular and Scalable Decision-Making Under Uncertainty
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Bayesian Networks (BNs) are established tools for letting agents reason under uncertainty in sequential decision-making. They split a joint distribution into local conditional mechanisms arranged on a directed acyclic graph, which makes them modular, interpretable, and ready to perform probabilistic inference. Their classical formulation, however, has limitations in both expressiveness and scale: each conditional is usually stored as a table or a linear-Gaussian form, and inference evaluates the graph one node and one query at a time. In this paper we introduce Neural Bayesian Networks (NBNs), in which each conditional is a differentiable, tensor-valued mechanism, while the graph and its factorization are unchanged. NBNs retain the modularity and local mechanisms of BNs, can represent any learnable conditional distribution, and run natively on GPUs. We also release NBN, a PyTorch-based library for learning and inference in NBNs, together with a public benchmark. Our evaluation shows gains in both expressiveness and scale: NBNs fit distributions that classical BN libraries struggle to represent, and on large networks and large batches of queries they run two orders of magnitude faster thanks to GPU parallelization. NBN is available at https://github.com/Giovannibriglia/NeuralBayesianNetworks.
Keywords
Bayesian networks; Decision Making; Neural Networks; Model-Based Agents
Marco Lippi
University of Florence
Florence, Italy
Franco Zambonelli
University of Modena and Reggio Emilia
Reggio Emilia, Italy
Classical BNs, however, were mostly designed for discrete variables and small graphs [33, 44]. A conditional probability table grows combinatorially with the parents and is undefined when a parent is continuous. Additionally, both exact and approximate inference evaluate the conditionals one node and one sample at a time. These limitations stem from representing each conditional as a scalar function and from evaluating the graph sequentially. They are thus inherited by mainstream BN software packages (Table 4).
We propose Neural Bayesian Network (NBN) as a new tool for autonomous agents when dealing with decision-making under uncertainty. NBNs keep the structural properties of BNs (i.e., the graph) while changing the conditionals to leverage more expressive and scalable representations based on neural networks. In an NBN each local conditional is a differentiable, tensor-valued mechanism that takes a batch of parent configurations and returns the full conditional distribution for each row (Figure 1). The graph and the factorization are exactly those of a BN. What changes is their computational representation: the mechanisms can be tabular, parametric, neural or non-parametric; every one of them exposes density, sampling, and gradients through one unified interface; and a whole layer of the graph is evaluated in one tensor operation on a GPU, for thousands of samples and evidence rows at once.
This advancement enables BNs to be used efficiently where they were not practical before: on continuous and non-Gaussian variables without reasonable discretization available, on networks of thousands of nodes, and for thousands of queries answered in one call. As such, NBNs make BNs seamless to integrate with learning-based agent architectures (e.g., reinforcement learning and cognitive architectures) and, more generally, with any machine learning toolchain: the NBN model is a differentiable module that is trained by gradient descent and runs on the same computational accelerators as a neural network (e.g., a GPU), while keeping the explicit graph, modular representation, and local mechanisms factorisation of the BNs' symbolic model.
Our contributions are:
(1) Representation. We define NBNs (Section 2) and show that they are semantically equivalent to classical BNs, end-to-end differentiable, and whose inference scales with the number of active nodes instead of samples or queries.
(2) Library. We release NBN, a PyTorch implementation with tabular, linear-Gaussian, neural and non-parametric mechanisms

Classical BN
scalar CPD per node: a table, or
fit by counting (MLE); queried by exact inference
one node, one sample, one query at a time
Neural BN
tensor-valued differentiable mechanism per node, any family
fit by gradient descent (or closed form); queried by VE / LW / AVI
one tensor op per graph layer: all samples and all queries at once, on the GPU
Figure 1: From a classical BN to an NBN. Left: each node stores a scalar conditional, evaluated one node and one configuration at a time. Right: each node stores a tensor-valued differentiable mechanism that maps a batch of B parent configurations to a batch of conditional distributions. The DAG and the factorization are unchanged.
and with exact, sampling-based and amortized inference engines, all batched on the GPU.
(3) Benchmark. We release a benchmark for BN learning and inference and compare NBN with state-of-the-art BN frameworks on discrete, Gaussian, and non-Gaussian networks of different dimensions (Section 3).
Although NBNs do not yet win all comparisons, the benchmark confirms their potential with regards to scalability and expressiveness, while also pointing to further assessment and development.
The paper is organised as follows. Section 2 introduces NBNs, contrasts them with BNs, and define their properties. Section 3 presents the design of the benchmark and Section 4 its results. Section 5 reviews related works, and Section 6 concludes.
2 Neural Bayesian Networks
A Neural Bayesian Network (NBN) is a BN whose conditional distributions are learnable modules. The graph acts as the architecture of the model: each node hosts one module, its mechanism, which receives the values of the node's parents and returns the distribution of the node (Figure 1). Learning fits the mechanisms to data and inference runs them along the graph, both on batches, as in a neural network.
Similarly to a BN, an NBN over variables is a directed acyclic graph (DAG) with and one conditional distribution per node, where are the parents of in [33, 44]. The joint distribution is the product of the conditionals,
so each variable is independent of its non-descendants given its parents. Differently from a BN, where a conditional is a conditional probability table (CPT) or a linear-Gaussian form, an NBN admits arbitrary representations of a conditional distribution: tabular entries, parametric and non-parametric expressions, and neural network based approximations, possibly mixed in the same graph.
Additionally, in a BN, parameter learning estimates the conditionals one at a time using the log-likelihood based on counting for a CPT and on the least squares method for a linear-Gaussian form [22]. In an NBN, instead, every conditional is differentiable, so the same log-likelihood can also be maximized by gradient descent on batches of data—for all the conditionals at once, and for those that admit no closed-form estimate, too. Also inference proceeds one variable at a time in a BN, by computing the posterior of query variables given observed evidence using variable elimination at a cost exponential in the treewidth of the graph [13]. In an NBN, instead, each conditional is evaluated once for a whole batch of samples and evidence assignments, so that many queries are answered in a single pass over the graph, by exact elimination where the treewidth allows it and by sampling elsewhere. As we will show in the following, BNs are special case of NBNs when the closed-form methods are feasible.
NBN is written in PyTorch [42]. The network is an nn.Module. A user builds it from a DAG and a per-node mechanism assignment, calls fit once, and then query. The benchmark, its configuration, and the complete results are released with the library.
2.1 Motivation
BNs are a common “world model” for agents that decide under uncertainty: they are the transition models of factored Markov decision processes in planning and reinforcement learning [10, 19, 30], and the diagnostic models used in troubleshooting, risk analysis, and healthcare [11, 34, 55].
Consider a decision-making agent that has to deal with a Markov decision process (MDP) formalised as with state , action and transition kernel . The MDP treats the state as a single object, so is one distribution over the joint next state for every pair , and its size grows exponentially with the number of state variables. If we know which current variables each next-state variable depends on, we can move to a factored MDP [10, 30], which is much lighter (Figure 2):
where the parents of each next-state variable are a few of the current state and action variables. This is a two-slice BN over . The same formulation applies to agents that face non-sequential scenarios, such as while doing diagnosis, where the BN has a single slice.
The agent has to deal with two problems:
P1 Learning. Given G and a dataset D of N samples, estimate every conditional of Eq. 1, for discrete and for continuous variables, without fixing the shape of the conditional in advance.
https://github.com/Giovannibriglia/NeuralBayesianNetworks

Figure 2: From an MDP to a factored MDP. When it is known which variables influence which, the transition kernel over the joint state becomes a two-slice BN with one conditional per next-state variable.
P2 Inference. Given the learned model, compute for query variables Q and evidence , for many evidence assignments at once.
In this work we assume that the structure is given and focus on parameter learning and inference, while leaving structure learning and the sampling of trajectories for planning to future work. More precisely, we make the standard assumptions of parameter learning in BNs. (A1) The graph G is given and the data distribution factorizes according to it. (A2) The data are complete, so every variable is observed in every sample, and the samples are independent and identically distributed. (A3) Each variable is a discrete variable with finitely many values or a real-valued scalar. All statements below are for a BN over d variables and cover both cases.
Classical BNs solve P1 and P2 only in part, because of three limitations of scalar conditionals evaluated one at a time. (L1) Representation, which limits P1. A CPT for has entries, with the number of values of , and is undefined for a continuous parent. Discretizing a parent introduces a binning parameter and loses information, and the linear-Gaussian alternative cannot represent multi-modal or heteroscedastic conditionals. Both fix the shape of the outcome uncertainty before seeing the data: a table needs the continuous outcome discretized, a Gaussian has one mode and a spread that does not depend on the parents. (L2) Sequential evaluation, which limits P1 and P2. A likelihood evaluation on one sample visits the nodes in order, and each visit is a scalar lookup or a scalar density. Nothing is shared across samples or across queries, so samples for evidence assignments cost scalar operations. (L3) Exact inference, which limits P2. Variable elimination on a network of treewidth costs with being the maximum cardinality [13], and it exists only for discrete and linear-Gaussian networks. Sampling avoids the exponent but inherits (L2).
A solution to P1 therefore needs conditionals that are not restricted to tables and linear-Gaussian forms (L1) and that are fit on batches of data (L2). A solution to P2 needs an evaluation whose cost does not grow with (L2), with exact inference where the treewidth allows it and batched sampling elsewhere (L3). As described in Section 2.2, NBNs provide all of these properties.
2.2 Formal definition and Properties
Let be a DAG over with . An NBN replaces each conditional by a parametrised mapping
where takes a batch of parent configurations and returns, for every row, a distribution over with a density , a sampler, and where it exists a reparametrised sampler. The joint is still Eq. 1:
Two design choices are worth emphasising here. First, returns the full conditional, not a sample or a point estimate, so learning and inference reach every mechanism through one interface. Second, are tensors on which autograd works, so a table, a linear-Gaussian form and a neural network are instances of the same class and can be mixed in one graph. All nodes at the same depth of are evaluated in one batched call.
With this representation, NBNs support the following properties.
PROPOSITION 2.1 (SEMANTIC EQUIVALENCE). Let be a BN on and an NBN on with for all and all arguments. Then , and satisfies the global Markov property of .
PROOF. Both joints are the product in Eq. 1 of the same factors. The Markov property depends only on the factorization [33]. ☐
Every classical BN is an NBN with tabular or linear-Gaussian mechanisms, and everything that follows from the factorization (e.g., conditional independences) holds for NBNs.
PROPOSITION 2.2 (DIFFERENTIABILITY). If every is differentiable in , the log-likelihood is differentiable in , depends only on the term of node , and the whole gradient is one backward pass.
PROOF. is a sum of terms depending on one ; reverse-mode differentiation of the sum evaluates all terms in a single pass.
Parameter learning (P1) is therefore gradient descent on , per node since the terms are independent (closed form where the family admits it), or jointly when a downstream differentiable objective couples the nodes.
PROPOSITION 2.3 (COST OF INFERENCE). Consider a query answered by ancestral simulation with S samples and B evidence assignments, and let be the active nodes. An NBN issues sequential tensor operations, each of cost , so the wall-clock time is ; a classical implementation issues scalar operations. For a fixed family, is constant in BS until the device saturates.
PROOF. Nodes outside A are barren and pruned. Within A, all nodes at the same depth have their parents available and are evaluated in one call over the B-S rows; there are depth( ) such levels. The scalar count is the number of (node, sample, row) triplets.
The claim is not that NBNs change the dependence on the graph, but that for inference (P2) they remove dependence on S and B up to device saturation, so one or a thousand queries cost the same—on a GPU the saturation point is far, on a CPU it is near.
These gains do not come at the cost of sacrificing the usual BN properties that are behind their adoption: modularity is preserved since each mechanism has its own parameters and can be inspected, refit, or replaced without touching the others; the explicit structure stands still (in the DAG), which a designer can read and edit; and the “one model for every query” workflow is also there, since a fitted NBN answers for any Q and E just like BNs.
Other routes to expressive and scalable probabilistic models give up at least one of them: see Section 5.
2.3 Learning and Inference Methods
Learning mechanisms differ in how much of the conditional is fixed in advance. Parametric mechanisms fix its form and have a closed-form fit: a probability table for a discrete child, by counting under a Dirichlet prior [22], and the linear-Gaussian form for a continuous one [35], by ridge regression [23]. The neural mechanism fixes the output form but not its dependence on the parents: a Mixture Density Network (MDN) [8] maps the parents with a multilayer perceptron to the parameters of a Gaussian mixture, fit by gradient descent on . It is still parametric, but linear in the number of parents and multi-modal. Non-parametric mechanisms fix no form and grow with the data: KNN is a local mixture over the training rows with the closest parents [53], and FlexCode [25] expands the conditional density in a cosine basis, one regression per coefficient.
Three inference engines answer . Variable Elimination (VE) [40, 57] is exact and discrete-only: it drops the nodes that cannot affect the query and sums out the others by multiplying their tables in one batched tensor contraction, so B evidence rows cost one pass. Being exponential in the induced width, it is our exact reference, not a scalable method. Likelihood Weighting (LW) [15, 51] simulates S samples with the evidence clamped and averages the query node, each sample weighted by the probability of the evidence; it needs only a sampler and a density per mechanism, so it works with every family. Amortized Variational Inference (AVI) [18, 36] avoids the samples LW wastes when the evidence is unlikely: a recognition network , trained once per model on the evidence lower bound [32], proposes samples close to the posterior for every query at constant cost; it falls back to LW when the proposal is worse than LW's own Monte-Carlo noise.
3 Benchmark Design
To the best of our knowledge, a fully reproducible benchmark for BNs has not been provided so far. The bnlearn repository [50] offers domains and their structures, and it is the usual source of test networks, but the benchmark configuration is unspecified: which queries to ask, how to obtain the ground truth, which metrics to report, or how to count a method that fails or does not finish is not established. In this way, results are hardly comparable thus advancements difficult to identify. Hence, we built one and release it with NBN. A benchmark is a configuration file that fixes the problems, the queries, the methods and the budgets, and the harness writes one row per problem, seed, method, query and metric, failures included. Its problems come from two sources: (i) the real domains of bnlearn, and (ii) synthetic domains that we generate. Synthetic networks are needed to define whatever network structure (varying nodes and edges configuration) with whatever underlying conditional probabilities (discrete, continuous gaussian and continuous non-gaussian), and evaluate sample efficiency, scalability and accuracy across whatever BN.
We use the benchmark on NBNto answer three research questions: RQ1. Where the classical BN assumptions hold, does NBN match the classical BN libraries?
RQ2. Where they do not hold, how much accuracy is gained?
RQ3. Does the cost model of Proposition 2.3 show up as wall-clock time when many queries are answered at once?
The numerical settings that follow are fields of the configuration file. We report here those needed to read the results, and all the others in Appendix A.
Problems. A problem is a triplet of family, number of nodes n, and seed. The family is the type of the conditionals of the true model: discrete, where every conditional is a CPT; linear-Gaussian; or non-Gaussian, where every conditional is a set of components forming a Gaussian mixture (that a linear-Gaussian model cannot represent correctly). The seed draws a sparse random DAG over the n nodes and then the parameters of every conditional. From the true model we draw a training set (20 480 rows), a test set that supplies the evidence values of the queries, and a reference set that supplies the ground truth. Every problem is repeated over 5 seeds. The real networks are the 13 networks of Section 4.4. We define a cell as the combination of one method on one problem.
Queries. A query has two components: a target variable, and an evidence set, which pairs each observed variable with its value. The evidence values are always copied from a row of the test set, so the evidence is a configuration that the true model produces. Three selectors choose targets and evidence variables, one per purpose:
(1) Random (accuracy): the target and the evidence variables are drawn uniformly for the problem, and the query is asked for the evidence values of 128 test rows; it measures the typical error over evidence values.
(2) Topological (real networks): targets are chosen by their role in the graph, among the most connected nodes (hubs), the nodes whose removal disconnects the graph (cut nodes), and the deep nodes with few descendants (terminals). Each target is asked in the prediction direction, with evidence among its ancestors, or in the diagnosis direction, with evidence among its descendants.
(3) Heaviest (scalability and speed): only the top-ranked hubs, cut nodes, and terminals are queried, each in both directions, once with the evidence observed (full) and once with it marginalized (empty).
Reference and metrics. For a discrete target the reference posterior is its empirical distribution among the reference samples that agree with the evidence, and the metric is the total variation (TV) between and the answer , [54]. For a continuous target the reference is a sample from obtained by likelihood weighting on the true model, and the metric is the 1-Wasserstein distance (W1) between the empirical distribution of this sample and the empirical distribution of the samples returned by the method, , where is the set of couplings of and [16]. In both cases the reference is a finite sample and not the exact posterior, so the measured accuracy has a floor that all methods share. On the discrete networks of the accuracy scenario it is a TV of about 0.06 at 10 nodes and 0.08 from 50 nodes on, which are the values exact engines reach in Figure 3. We use a sampled reference because an exact one is not available for every family and size: variable elimination on the true model is exponential in the treewidth, and non-Gaussian conditionals have no closed-form posterior. Computing exact references when tractable is left for future work. The main text reports this accuracy metric (TV or W1) for the accuracy, scalability, and real-network scenarios, and the time per query for the speed batching scenario, measured as the wall-clock time of one call divided by the number of answered queries. Complete fit and query times are in Appendix B.
Budgets and failures. Every cell has a budget of 1200 s for the fit, a separate budget of 1200 s for its queries, and a memory cap: 80% of RAM ( 100 GB on our server, that is a more favourable scenarios for cpu-based libraries e.g. pgmpy.), and the 12 GB of the GPU. It ends with a status: ok, timeout, oom or not_supported. In the figures a bar is the interquartile mean (IQM) over the seeds a method solved, as [2] suggests; f/n is printed when f of n seeds failed, and a missing bar indicates the failure status.
Scenarios. Each scenario is one configuration. Accuracy fixes the query load (128 random queries) and varies the family and the size, : on the discrete and the linear-Gaussian family the classical model is correct, which isolates RQ1, and on the non-Gaussian family it is misspecified, which isolates RQ2. Scalability pushes the network size to on the heaviest queries and records where each method stops. Batching fixes the network size ( ) and varies only the number of queries answered in one call, which is the variable of Proposition 2.3 (RQ3). Real networks repeat the accuracy scenario on published structures with topological queries. Learning scores the fitted conditionals without any query and addresses P1.
Methods and hardware. The comparison baselines are pgmpy with maximum-likelihood and with Bayesian CPTs, both queried by its variable elimination; pgmpy linear-Gaussian, which conditions the joint Gaussian in closed form; pomegranate, which is discrete only and uses its built-in loopy belief propagation; and Pyro, where the BN is written as a program with smoothed tables or linear-Gaussian conditionals and queried by importance sampling from the prior with 50 particles (the largest number its sequential sampler affords within the budgets). On continuous networks pgmpy and Pyro always fit linear-Gaussian conditionals, so on the non-Gaussian family they are the misspecified classical model.
NBN runs every applicable pair of a mechanism and an engine, with 2048 particles for the sampling engines (16 in the batching scenario, which measures time only). To keep the figures readable, each panel shows all applicable external baselines plus the best NBN methods of the family, selected by accuracy. Appendix B reports every method on every scenario. All runs use one server with a 20-core CPU, 126 GB of RAM and one GPU with 12 GB of memory; NBN and pomegranate run on the GPU, pgmpy on the CPU, and Pyro on the CPU except in the batching scenario.
4 Experimental Results
Section 2 makes two claims: an NBN keeps what a BN offers, while enhancing expressiveness of conditionals and scaling up inference performance. The results support both, within limits that the benchmark makes visible. In terms of our research questions:
RQ1. No loss where the classical model is right (Proposition 2.1). On discrete networks, exact inference in NBN returns the same TV as pgmpy at every size, and on real networks it matches or improves it on seven out of eight; learning is identical as well. The exception is inference on linear-Gaussian networks, where the closed form of pgmpy is more accurate than our sampled posterior (W1 0.039 against 0.074 at 1000 nodes).
RQ2. Expressiveness pays where it is wrong. On non-Gaussian networks the MDN has between one third and 60% of the W1 of a linear-Gaussian model, and achieves better held-out likelihood: where the outcome has several modes or a state-dependent spread, the linear-Gaussian family misstates the uncertainty while the MDN learns its shape.
RQ3. The cost model holds on the GPU (Proposition 2.3). With the sampling engines the time per query falls by two orders of magnitude between one query and a batch of 1024, down to tens of microseconds.
While pgmpy achieves top accuracy wherever one of its two families is the right model, it cannot represent non-Gaussian conditionals and answers one query at a time. pomegranate leverages the GPU, but its loopy belief propagation returns undefined posteriors or exceeds budget on all networks but the smallest. Pyro runs a generic sequential importance sampler, which the budget limits to 50 particles: it has the highest error on all synthetic families and times out from 500 nodes onwards. The performance of NBN can still be improved, and the benchmark shows where. The sampling engines pay a Monte-Carlo error where a closed form exists, the MDN exceeds the fit budget between 100 and 500 nodes, and the nearest-neighbour mechanism exhausts the GPU memory at 500.
Below, NBN methods are named by their mechanisms and engines: cat+VE is categorical table queried by variable elimination; likewise for linear-Gaussian (LG) and MDN mechanisms, and for likelihood weighting (LW) and amortized variational inference (AVI).
4.1 Inference accuracy (RQ1, RQ2)
Figure 3 shows the accuracy of the 128 queries for each family.
Discrete. cat+VE and pgmpy return the same TV at every size because they run exact inference on the same maximum-likelihood tables: this is Proposition 2.1, measured. Their common value is the floor of the reference (Section 3). The sampling engines of NBN stay within 0.01 of it, so on discrete networks approximation costs little.
Linear-Gaussian. This is the one family where a baseline is ahead: pgmpy conditions the joint Gaussian in closed form, while NBN samples. The gap grows with the size because, in deeper networks, fewer prior samples agree with the evidence: the median effective sample size falls from all 2048 particles at 10 nodes to 13% of discrete

continuous (Gaussian)
continuous (non-Gaussian)

Figure 3: Inference accuracy against network size on synthetic networks (TV for discrete, W1 for continuous, lower is better). All applicable external baselines are shown, plus the selected NBN methods per family. A missing bar is a method that failed on every seed, with its status printed; marks failed seeds out of .
them at 1000. The error is due to the engine, not the model, and a closed-form engine for all-Gaussian networks would remove it.
Non-Gaussian. Here the model is decisive: every linear-Gaussian method has the same error, in NBN or in pgmpy and whatever the engine, because the family cannot represent the data. The MDN has one third to 60% of that error and kNN one half to three quarters. The price is paid at fit time (Table 13 in Appendix B.1): the MDN exceeds the fit budget at 500 nodes, where kNN runs out of memory, so beyond 100 nodes only the misspecified models remain.
Table 1: Accuracy on the heaviest queries with full evidence against network size, up to 10 000 nodes (IQM over seeds, lower is better). marks failed seeds out of . Bold: fewest failed seeds, then best value. Times in Appendix B.2.
| Method | n=10 | n=100 | n=1000 | n=10000 |
|---|---|---|---|---|
| Discrete, TV | ||||
| pgmpy Bayes+VE | 0.0491 | 0.0578 | 0.0645 | 0.0323 (1/5) |
| pgmpy MLE+VE | 0.0438 | 0.0406 | 0.0582 | 0.0484 |
| pomegranate | 0.0276 (2/5) | nan | nan | timeout |
| Pyro IS | 0.120 | 0.188 | 0.151 | 0.141 (1/5) |
| NBN cat+VE | 0.0435 | 0.0476 | 0.0516 | 0.0376 (2/5) |
| NBN cat+LW | 0.0495 | 0.0600 | 0.0619 | 0.0586 |
| Linear-Gaussian, W1 | ||||
| pgmpy LG | 0.0303 | 0.0553 | 0.0378 | 0.0466 |
| Pyro IS | 0.138 | 0.330 | 0.338 | 0.226 (1/5) |
| NBN LG+LW | 0.0291 | 0.0526 | 0.0652 | 0.0560 |
| NBN MDN+LW | 0.0326 | 0.0534 | timeout | timeout |
| kNN+LW | 0.0557 | 0.102 | oom | oom |
| Non-Gaussian, W1 | ||||
| pgmpy LG | 0.115 | 0.142 | 0.0830 | 0.101 |
| Pyro IS | 0.232 | 0.193 | 0.175 | 0.209 (1/5) |
| NBN LG+LW | 0.125 | 0.137 | 0.0917 | 0.0992 |
| NBN MDN+LW | 0.0504 | 0.0414 (1/5) | timeout | timeout |
| NBN kNN+LW | 0.0755 | 0.0779 | oom | oom |
4.2 Scalability
Table 1 pushes the heaviest queries to 10 000 nodes. Accuracy stays in the same range at every size; what this scenario reveals is why each method stops and how long a query takes. Exact inference is bounded by the elimination itself. pgmpy completes every seed but needs tens of seconds per query from 1000 nodes; cat+VE answers in 0.2 to 0.4 s, two orders of magnitude faster, and exceeds the 12 GB of the GPU on two of five seeds at 10 000 nodes. The sampling engines have no such wall: cat+LW and LG+LW finish every seed at 10 000 nodes, where LG+LW is also faster than the closed form of pgmpy (2.6 s against 17.5 s per query), being the fastest up to 1000 nodes. The flexible mechanisms stop earlier due to the cost of learning: at 1000 nodes the MDN exceeds the fit budget and kNN the memory.
4.3 Batched queries (RQ3)
Proposition 2.3 postulates that the cost of a batch does not grow with its size until the device saturates, so the time per query should fall as . We fix 50-node networks and ask each heaviest query for the evidence values of different rows (Figure 4). The sampling engines follow the prediction closely up to , where a query costs about one hundredth of a single one, and then flattens as the GPU saturates: at the gain is for cat+AVI and for LG+AVI, down to 0.09 and 0.05 ms per query. Exact cat+VE is the fastest method on one query (2.8 ms) but gains only : every factor of the elimination carries the batch axis, so its work grows with and batching removes only the per-call overhead. Among the baselines only pomegranate batches, and at it is 60 times slower than cat+AVI; pgmpy answers one query at a time. The gain is in the batch, not in the latency of one query: on a single continuous query the closed form of pgmpy takes 2.6 ms and NBN 12 ms. An agent that asks one question at a time is better served by the classical code; one that scores many candidate actions or particles at once is the case NBNs are built for.
discrete
continuous (Gaussian)
continuous (non-Gaussian)



Figure 4: Time per query vs. batch size (log scale) on 50-node networks, full evidence. Non-batching methods are at only.
4.4 Real networks
Table 2 repeats the accuracy comparison on thirteen bnlearn networks: eight discrete ones, from 8 to 1041 nodes, two Gaussian ones, and three conditional linear-Gaussian (CLG) ones, which mix discrete and continuous variables.
The conclusions of the synthetic scenarios carry over. On the discrete networks cat+VE has the lowest TV on five, including the two largest, and is within 0.001 of the best on two more; pgmpy is better on mildew only. Amortized inference suffers more here than on synthetic networks (up to four times the TV of exact inference), so the exact engine is the one to use whenever the treewidth allows it. On the Gaussian networks NBN is again close to the closed form of pgmpy. The CLG networks are where coverage matters: pgmpy and
pomegranate have no applicable engine, and the best NBN mechanism is below Pyro on all three. Which mechanism is best, however, depends on the network: the MDN wins on sangiovese and mehra and has six times the error of Pyro on healthcare, where kNN wins. The choice of the mechanism is a modelling decision, and the benchmark is the tool to make it.
4.5 Parameter learning and sample efficiency
The learning scenarios score the fitted conditionals with no query: by the parameter-recovery TV on discrete networks, the distance between learned and true rows of the CPTs, and by held-out negative log-likelihood (NLL) per node on continuous ones (Appendix A).
Table 2: Accuracy on bnlearn networks, grouped by kind and ordered by node count (IQM over seeds; TV for discrete, W1 for Gaussian and CLG, lower is better). Each block names the method of each library; – denotes no applicable engine. pgmpy with Bayesian estimates and the other NBN engines are in Appendix B.4.
| Network (n) | pgmpy | pomegr. | Pyro | NBN | NBN |
|---|---|---|---|---|---|
| Discrete, TV | MLE+VE | BP | IS | cat+VE | cat+AVI |
| asia (8) | 0.00343 | 0.00380 | 0.0336 | 0.00354 | 0.00478 |
| sachs (11) | 0.0128 | 0.0122 | 0.0818 | 0.0120 | 0.0162 |
| mildew (35) | 0.0325 | nan | 0.287 | 0.0465 | 0.0703 |
| barley (48) | 0.0275 | nan | 0.215 | 0.0240 | 0.0401 |
| hailfinder (56) | 0.0203 | 0.0208 | 0.136 | 0.0206 | 0.0266 |
| diabetes (413) | 0.0393 (1/5) | nan | timeout | 0.0343 | 0.128 |
| link (724) | 0.00197 | timeout | timeout | 0.00174 | 0.00612 |
| munin (1041) | 0.00464 | timeout | timeout | 0.00401 | 0.0105 |
| Gaussian, W1 | LG | - | IS | LG+AVI | kNN+LW |
| ecoli70 (46) | 0.0418 | - | 0.245 | 0.0541 | 0.111 |
| arth150 (107) | 0.0210 | - | 0.107 | 0.0212 | 0.0418 |
| CLG, W1 | - | - | IS | MDN+LW | kNN+LW |
| healthcare (7) | - | - | 106 | 625 | 23.4 |
| sangiovese (15) | - | - | 0.0583 | 0.0242 | 0.0280 |
| mehra (24) | - | - |
Table 3: Sample efficiency on 50-node networks against the number of training rows (IQM over seeds, lower is better): parameter-recovery TV on discrete networks, held-out NLL per node on continuous ones. timeout: the 1200 s fit budget was exceeded on every seed. Fit times and the network-size sweep are in Appendices B.5 and B.6.
| Method | ||||
|---|---|---|---|---|
| Discrete, parameter-recovery TV | ||||
| pgmpy Bayes | 0.0977 | 0.0474 | 0.0335 | 0.0236 |
| pgmpy MLE | 0.0979 | 0.0474 | 0.0336 | 0.0236 |
| pomegranate | 0.0979 | 0.0474 | 0.0336 | 0.0236 |
| Pyro | 0.0847 | 0.0453 | 0.0328 | 0.0233 |
| NBN cat | 0.0979 | 0.0474 | 0.0336 | 0.0236 |
| NBN cat (Bayes) | 0.0847 | 0.0453 | 0.0328 | 0.0233 |
| Gaussian, NLL per node | ||||
| pgmpy LG | 0.943 | 0.942 | 0.944 | 0.945 |
| NBN LG | 0.935 (1/5) | 0.942 | 0.944 | 0.945 |
| NBN MDN | 0.953 | 0.946 | 0.958 (1/5) | timeout |
| NBN kNN | 1.01 | 0.988 | 0.981 | 0.966 (1/5) |
| Non-Gaussian, NLL per node | ||||
| pgmpy LG | 1.26 | 1.27 | 1.27 | 1.27 |
| NBN LG | 1.26 | 1.27 | 1.27 | 1.27 |
| NBN MDN | 1.20 | 1.19 | 1.19 | timeout |
| NBN kNN | 1.25 | 1.23 | 1.22 | 1.21 |
When the model is correct, NBN learns what competitors do, as the estimator is the same: the tabular mechanism equals the max-likelihood tables of pgmpy and pomegranate at all sizes, its smoothed variant equals the tables of Pyro, and the linear-Gaussian mechanism equals the least squares of pgmpy (Table 3; Appendix B.5). It is also faster: a 1000-node network is fitted in 2.1 s (tables) and 2.6 s (linear-Gaussian), against 9.8 s and 4.0 s for pgmpy. The accuracy drop when data is Gaussian is negligible: the NLL of the MDN is within 0.004 of the exact estimator.
When the model is wrong, more data does not repair it (Table 3). On 50-node non-Gaussian networks the NLL of the linear-Gaussian models stays at 1.26–1.27 from 4096 to 65 536 rows, while the MDN is at 1.20 with 4096 rows already and kNN improves steadily to 1.21. Flexibility is thus sample-efficient but not compute-efficient: the fit time of the MDN grows linearly with the rows and nodes, exceeding the budget at 65 536 rows and from 100 nodes (Appendix B.6).
5 Related Works
NBNs extend classical BNs in two directions, the expressiveness of the conditionals and the efficiency and scale of learning and inference; we review the works that pursue each of them.
Expressiveness. Kernel density estimation was used for continuous conditionals in Bayesian classifiers [28], and non-parametric BNs based on kernels or copulas followed [21, 24, 38]. Semiparametric BNs [4, 5] mix linear-Gaussian and kernel conditionals in one network; surveys of inference with continuous variables are [39, 48]. Neural structural causal models replace each structural equation with a neural density, typically a normalizing flow [17, 26, 31, 43, 56]. Closest to ours in name, the Neural Bayesian Network Understudy [46] trains a single Neural network to approximate the conditional probabilities of a given BN, with its independences encoded through training. These works fix one family of conditionals and one inference procedure. At the other extreme, deep generative models such as normalizing flows [41, 47] and neural world models [20] are expressive but hide the dependencies in the weights of one network: there is no local conditional to inspect or replace, and the posterior given arbitrary evidence is not directly available. An NBN changes the representation rather than adding a family. With tensor-valued mechanisms the BN is kept exactly (Proposition 2.1); tabular, linear-Gaussian, neural and non-parametric [25] mechanisms can be mixed in one graph and trained by gradient, also jointly with a downstream objective (Proposition 2.2); and any mechanism that can sample and evaluate a density is queried by the same batched engine, with no family-specific algorithm (Proposition 2.3).
Efficiency and scalability. Exact inference has been parallelized on multi-core CPUs [27] and on GPUs [58], and written as tensor contractions [40], but only for discrete networks and at a cost that stays exponential in the treewidth. Probabilistic circuits [12, 45] keep inference tractable and batched, but trade the per-variable conditionals for latent sum and product units. When exact inference is too expensive, a BN is queried by sampling. Likelihood weighting (Section 2.3) is simple and general, but its samples are drawn without looking at the evidence, so most of them are wasted when the evidence is unlikely. Amortized inference [18, 36] trains a neural network to propose samples that already agree with the
Table 4: Bayesian-network and probabilistic-modeling libraries. Disc.: discrete; LG: linear-Gaussian; NG: continuous non-Gaussian. Batch: the API accepts many queries in one call. GPU: BN queries run in parallel on the accelerator. Diff.: differentiable conditionals. do: native interventions. √ supported, • partial, × absent.
| Library | Families | Compute | Capabilities | ||||
|---|---|---|---|---|---|---|---|
| Disc. | LG | NG | Batch | GPU | Diff. | do | |
| pgmpy [3] | ✓ | ✓ | ✕ | ✓ | ✕ | ✕ | ● |
| pyAgrum [14] | ✓ | ✕ | ✕ | ✓ | ✕ | ✕ | ✕ |
| bnlearn [50] | ✓ | ✓ | ✕ | ✓ | ✕ | ✕ | ✕ |
| CausalNex [6] | ✓ | ✕ | ✕ | ✓ | ✕ | ✕ | ✓ |
| pomegranate [49] | ✓ | ✓ | ● | ✓ | ● | ✕ | ✕ |
| PyMC [1] | ✓ | ✓ | ✓ | ● | ✓ | ● | ✕ |
| Pyro [7] | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ● |
| DoWhy [52] | ✓ | ✓ | ● | ✕ | ✕ | ✕ | ✓ |
| NBN (ours) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
evidence and reuses it for every later query. We do not propose a new estimator: NBNs change how these estimators are executed. All the nodes at the same depth of the graph are evaluated in one tensor operation over every particle and every evidence assignment, so the cost of a query stops growing with the number of samples and of queries (Proposition 2.3).
Libraries. Table 4 summarizes NBNs competitors. Classical BN libraries (pgmpy [3], pyAgrum [14], bnlearn [50], CausalNex [6]) implement tabular or linear-Gaussian conditionals with exact inference; they run on the CPU and accept several queries in one call but execute them one by one, which are the limitations (L1) and (L2) of Section 2.1. pomegranate [49] is PyTorch-based and runs on the GPU, but its BN inference is limited to discrete networks and to loopy belief propagation, which is not guaranteed to converge on graphs with loops. Probabilistic programming systems (Pyro [7], PyMC [1]) support any distribution and GPU execution, but they do not expose the BN as an object: the graph, the per-node conditionals, and the inference procedure over them have to be written by hand for every model, and a generic sampler cannot eliminate variables exactly, prune the nodes that a query does not need, or evaluate a level of the graph at once. DoWhy [9, 52] estimates the causal effect of a treatment on an outcome and does not answer posterior queries over arbitrary variables.
To the best of our knowledge, no existing library combines an explicit DAG with differentiable conditionals of arbitrary family and GPU-batched learning and inference, which is the gap NBN fills. Our benchmark compares against one representative per class: pgmpy for the classical libraries, pomegranate as the PyTorch-based one, and Pyro as the probabilistic programming system.
6 Conclusions and Future Works
Neural Bayesian Networks (NBNs) are an extension to Bayesian networks that combine explicit graphical structure with learnable, tensor-valued conditional mechanisms. NBNs preserve the probabilistic factorization and modularity of BNs while bringing heterogeneous conditional models into a common framework for learning and GPU-batched inference. The accompanying PyTorch library and reproducible benchmark provide a basis for evaluating the trade-offs between expressiveness, accuracy, and computational cost. NBNs provide to autonomous agents a tool for decision-making under uncertainty that combines structured world models with the flexibility and computational tools of modern machine learning. Explicit dependencies and separately replaceable mechanisms support adaptation of individual model components, while batched inference serve agents that evaluate many candidate actions or hypotheses. Evaluation of NBNs within agent decision making tasks (e.g. causal reinforcement learning), removing the assumption of having the graph available, evaluating sampling, and considering CPU execution along GPU are amongst the future works we are considering.
References
[1] Oriol Abril-Pla, Virgile Andreani, Colin Carroll, Larry Dong, Christopher J Fonesbeck, Maxim Kochurov, Ravin Kumar, Junpeng Lao, Christian C Luhmann, Osvaldo A Martin, et al. 2023. PyMC: a modern, and comprehensive probabilistic programming framework in Python. PeerJ Computer Science 9 (2023), e1516.
[2] Rishabh Agarwal, Max Schwarzer, Pablo Samuel Castro, Aaron C Courville, and Marc Bellemare. 2021. Deep reinforcement learning at the edge of the statistical precipice. Advances in neural information processing systems 34 (2021), 29304–29320.
[3] Ankur Ankan and Johannes Textor. 2024. pgmpy: A python toolkit for bayesian networks. Journal of Machine Learning Research 25, 265 (2024), 1–8.
[4] David Atienza, Concha Bielza, and Pedro Larrañaga. 2022. Semiparametric Bayesian Networks. Information Sciences 584 (2022), 564–582. doi:10.1016/j.ins.2021.10.074
[5] David Atienza, Pedro Larrañaga, and Concha Bielza. 2022. Hybrid Semiparametric Bayesian Networks. In TEST, Vol. 31. 299–327.
[6] Paul Beaumont, Ben Horsburgh, Philip Pilgerstorfer, Angel Droth, Richard Oentaryo, Steven Ler, Hiep Nguyen, Gabriel Azevedo Ferreira, Zain Patel, and Wesley Leong. 2021. CausalNex. URL https://github.com/quantumblacklab/s/causalnex (2021).
[7] Eli Bingham, Jonathan P Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karaletsos, Rohit Singh, Paul Szerlip, Paul Horsfall, and Noah D Goodman. 2019. Pyro: Deep universal probabilistic programming. Journal of machine learning research 20, 28 (2019), 1–6.
[8] Christopher M. Bishop. 1994. Mixture Density Networks. Technical Report NCRG/94/004. Aston University.
[9] Patrick Blöbaum, Peter Götz, Kailash Budhathoki, Atalanti A Mastakouri, and Dominik Janzing. 2024. DoWhy-GCM: An extension of DoWhy for causal inference in graphical causal models. Journal of Machine Learning Research 25, 147 (2024), 1–7.
[10] Craig Boutliier, Richard Dearden, Moisés Goldszmidt, et al. 1995. Exploiting structure in policy construction. In IJCAI, Vol. 14. 1104–1113.
[11] John S. Breese and David Heckerman. 1996. Decision-Theoretic Troubleshooting: A Framework for Repair and Experiment. In UAI '96: Proceedings of the Twelfth Annual Conference on Uncertainty in Artificial Intelligence, Reed College, Portland, Oregon, USA, August 1-4, 1996, Eric Horvitz and Finn Verner Jensen (Eds.). Morgan Kaufmann, 124–132. https://dslpitt.org/uai/displayArticleDetails.jsp?mmnu=1&smnu=2&article_id=360&proceeding_id=12
[12] YooJung Choi, Antonio Vergari, and Guy Van den Broeck. 2020. Probabilistic Circuits: A Unifying Framework for Tractable Probabilistic Models. Technical Report. University of California, Los Angeles. http://starai.cs.ucla.edu/papers/ProbCirc20.pdf
[13] Gregory F. Cooper. 1990. The Computational Complexity of Probabilistic Inference Using Bayesian Belief Networks. Artif. Intell. 42, 2-3 (1990), 393–405. doi:10.1016/0004-3702(90)90060-D
[14] Gaspard Ducamp, Christophe Gonzales, and Pierre-Henri Wuillemin. 2020. aGrUM/pyAgrum: a toolbox to build models and algorithms for Probabilistic Graphical Models in Python. In International Conference on Probabilistic Graphical Models. PMLR.
[15] Robert Fung and Kuo-Chu Chang. 1989. Weighing and Integrating Evidence for Stochastic Simulation in Bayesian Networks. In Proceedings of the 5th Conference on Uncertainty in Artificial Intelligence (UAI). 209–219.
[16] Peyré Gabriel and Cuturi Marco. 2019. Computational optimal transport with applications to data sciences. Foundations and trends® in machine learning 11, 5-6 (2019), 355–607.
[17] Tomas Geffner, Javier Antorán, Adam Foster, Wenbo Gong, Chao Ma, Emre Kiciman, Amit Sharma, Angus Lamb, Martin Kukla, Nick Pawlowski, Miltiadis Allamanis, and Cheng Zhang. 2022. Deep End-to-end Causal Inference. arXiv
preprint arXiv:2202.02195 (2022).
[18] Samuel J. Gershman and Noah D. Goodman. 2014. Amortized Inference in Probabilistic Reasoning. Proceedings of the Annual Meeting of the Cognitive Science Society 36 (2014).
[19] Carlos Guestrin, Daphne Koller, Ronald Parr, and Shobha Venkataraman. 2003. Efficient Solution Algorithms for Factored MDPs. Journal of Artificial Intelligence Research 19 (2003), 399–468.
[20] David Ha and Jürgen Schmidhuber. 2018. World models. arXiv preprint arXiv:1803.10122 2, 3 (2018).
[21] Anca Hanea, Oswaldo Morales Napoles, and Daniel Ababei. 2015. Non-Parametric Bayesian Networks: Improving Theory and Reviewing Applications. Reliability Engineering & System Safety 144 (2015), 265–284.
[22] David Heckerman. 1998. A tutorial on learning with Bayesian networks. Learning in graphical models (1998), 301–354.
[23] Arthur E. Hoerl and Robert W. Kennard. 1970. Ridge Regression: Biased Estimation for Nonorthogonal Problems. Technometrics 12, 1 (1970), 55–67.
[24] Katja Ickstadt, Björn Bornkamp, Marco Grzegorczyk, Jakob Wieczorek, M. Rashid Sheriff, Hernán E. Grecco, and Eli Zamir. 2010. Nonparametric Bayesian Networks. Bayesian Statistics 9 (2010).
[25] Rafael Izbicki and Ann B. Lee. 2017. Converting High-Dimensional Regression to High-Dimensional Conditional Density Estimation. Electronic Journal of Statistics 11, 2 (2017), 2800–2831.
[26] Adrián Javaloy, Pablo Sánchez-Martín, and Isabel Valera. 2023. Causal Normalizing Flows: From Theory to Practice. In Advances in Neural Information Processing Systems, Vol. 36.
[27] Jiantong Jiang, Zeyi Wen, Atif Mansoor, and Ajmal Mian. 2023. POSTER: Fast Parallel Exact Inference on Bayesian Networks. In Proceedings of the 28th ACM SIGPLAN Annual Symposium on Principles and Practice of Parallel Programming (PPoPP). doi:10.1145/3572848.3577476
[28] George H. John and Pat Langley. 1995. Estimating Continuous Distributions in Bayesian Classifiers. In Proceedings of the 11th Conference on Uncertainty in Artificial Intelligence (UAI). 338–345.
[29] Leslie Pack Kaelbling, Michael L Littman, and Anthony R Cassandra. 1998. Planning and acting in partially observable stochastic domains. Artificial intelligence 101, 1-2 (1998), 99–134.
[30] Michael Kearns and Daphne Koller. 1999. Efficient Reinforcement Learning in Factored MDPs. In Proceedings of the 16th International Joint Conference on Artificial Intelligence (IJCAI). 740–747.
[31] Ilyes Khemakhem, Ricardo Monti, Robert Leech, and Aapo Hyvärinen. 2021. Causal Autoregressive Flows. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics (AISTATS). 3520–3528.
[32] Diederik P. Kingma and Max Welling. 2014. Auto-Encoding Variational Bayes. In International Conference on Learning Representations (ICLR).
[33] Daphne Koller and Nir Friedman. 2009. Probabilistic Graphical Models: Principles and Techniques. MIT Press.
[34] Evangelia Kyrimi, Scott McLachlan, Kudakwashe Dube, Mariana R. Neves, Ali Fahmi, and Norman Fenton. 2021. A Comprehensive Scoping Review of Bayesian Networks in Healthcare: Past, Present and Future. Artificial Intelligence in Medicine 117 (2021), 102108.
[35] Steffen L. Lauritzen and Nanny Wermuth. 1989. Graphical Models for Associations between Variables, some of which are Qualitative and some Quantitative. The Annals of Statistics 17, 1 (1989), 31–57.
[36] Tuan Anh Le, Atilim Güneş Baydin, and Frank Wood. 2017. Inference Compilation and Universal Probabilistic Programming. In Proceedings of the 20th International Conference on Artificial Intelligence and Statistics (AISTATS). 1338–1348.
[37] Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. 2020. Offline Reinforcement Learning: Tutorial, Review, and Perspectives on Open Problems. arXiv preprint arXiv:2005.01643 (2020).
[38] Dimitris Margaritis. 2005. Distribution-Free Learning of Bayesian Network Structure in Continuous Domains. Proceedings of the AAAI Conference on Artificial Intelligence (2005).
[39] Joaquin Mori, Josep Maria Mateo-Sanz, and Antonio Salmerón. 2016. Inference in Hybrid Bayesian Networks: A Survey. International Journal of Approximate Reasoning (2016).
[40] Fritz Obermeyer, Eli Bingham, Martin Jankowiak, Neeraj Pradhan, Justin Chiu, Alexander Rush, and Noah Goodman. 2019. Tensor Variable Elimination for Plated Factor Graphs. In Proceedings of the 36th International Conference on Machine Learning (ICML).
[41] George Papamakarios, Theo Pavlakou, and Iain Murray. 2017. Masked Autoregressive Flow for Density Estimation. In Advances in Neural Information Processing Systems, Vol. 30.
[42] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. 2019. PyTorch: An Imperative Style, High-Performance Deep Learning Library. Advances in Neural Information Processing Systems 32 (2019).
[43] Nick Pawlowski, Daniel C. Castro, and Ben Glocker. 2020. Deep Structural Causal Models for Tractable Counterfactual Inference. In Advances in Neural Information Processing Systems, Vol. 33.
[44] Judea Pearl. 1988. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference. Morgan Kaufmann.
[45] Robert Peharz, Steven Lang, Antonio Vergari, Karl Stelzner, Alejandro Molina, Martin Trapp, Guy Van den Broeck, Kristian Kersting, and Zoubin Ghahramani. 2020. Einsum Networks: Fast and Scalable Learning of Tractable Probabilistic Circuits. In Proceedings of the 37th International Conference on Machine Learning (ICML) (Proceedings of Machine Learning Research, Vol. 119). 7563–7574.
[46] Paloma Rabaey, Cedric De Boom, and Thomas Demeester. 2022. Neural Bayesian Network Understudy. arXiv preprint arXiv:2211.08243 (2022).
[47] Danilo Jimenez Rezende and Shakir Mohamed. 2015. Variational Inference with Normalizing Flows. In Proceedings of the 32nd International Conference on Machine Learning (ICML) (Proceedings of Machine Learning Research, Vol. 37). 1530–1538.
[48] Antonio Salmerón, Rafael Rumí, Helge Langseth, Thomas D. Nielsen, and Anders L. Madsen. 2018. A Review of Inference Algorithms for Hybrid Bayesian Networks. Journal of Artificial Intelligence Research 62 (2018), 799–828.
[49] Jacob Schreiber. 2018. Pomegranate: fast and flexible probabilistic modeling in python. Journal of Machine Learning Research 18, 164 (2018), 1–6.
[50] Marco Scutari. 2010. Learning Bayesian Networks with the bnlearn R Package. Journal of Statistical Software 35, 3 (2010), 1–22.
[51] Ross D. Shachter and Mark A. Peot. 1989. Simulation Approaches to General Probabilistic Inference on Belief Networks. In Proceedings of the 5th Conference
on Uncertainty in Artificial Intelligence (UAI). 221–231.
[52] Amit Sharma and Emre Kiciman. 2020. DoWhy: An end-to-end library for causal inference. arXiv preprint arXiv:2011.04216 (2020).
[53] Charles J. Stone. 1977. Consistent Nonparametric Regression. The Annals of Statistics 5, 4 (1977), 595–620.
[54] Alexandre B. Tsybakov. 2009. Introduction to Nonparametric Estimation. Springer. doi:10.1007/B13794
[55] Philippe Weber, Gabriela Medina-Oliva, Christophe Simon, and Benoît Iung. 2012. Overview on Bayesian Networks Applications for Dependability, Risk Analysis and Maintenance Areas. Engineering Applications of Artificial Intelligence 25, 4 (2012), 671–682.
[56] Kevin Xia, Kai-Zhan Lee, Yoshua Bengio, and Elias Bareinboim. 2021. The Causal-Neural Connection: Expressiveness, Learnability, and Inference. In Advances in Neural Information Processing Systems, Vol. 34.
[57] Nevin Lianwen Zhang and David Poole. 1994. A Simple Approach to Bayesian Network Computations. In Proceedings of the 10th Canadian Conference on Artificial Intelligence. 171–178.
[58] Lu Zheng, Ole Mengshoel, and Jike Chong. 2011. Belief Propagation by Message Passing in Junction Trees: Computing Each Message Faster Using GPU Parallelization. In Proceedings of the 27th Conference on Uncertainty in Artificial Intelligence (UAI). 822–830.
A Benchmark Design – Extended Version
This appendix gives the settings of the benchmark that Section 3 leaves out. All of them are fields of the released configuration files or defaults of the released code, and can be changed.
Synthetic generator. The seed draws a DAG over ordered nodes, where each earlier node becomes a parent of a later one with probability 0.2 and a node keeps at most four parents. The cap bounds the size of a conditional as grows: with four values per variable, a CPT has at most entries. In the discrete family every variable has four values and every row of a CPT is the softmax of standard-normal logits. In the linear-Gaussian family every node has weights of variance , a standard-normal bias and a noise scale drawn uniformly in [0.3, 1]. In the non-Gaussian family every node is a three-component Gaussian mixture: the component means are linear in the parents, with weights of standard deviation and offsets for standard-normal , which are skewed; the component scales are uniform in [0.3, 0.7]; and the mixing weights are drawn from a flat Dirichlet distribution and do not depend on the parents.
Data. The training set has 20 480 rows in the accuracy, scalability and learning scenarios and 4096 rows in the batching scenario; the sample-efficiency study uses 4096, 16 384, 32 768 and 65 536 rows. On real networks it has 10 240, 20 480, 40 960 or 81 920 rows, for networks with up to , , or more parameters. The test set has 4096 rows (1024 in the batching scenario and on real networks). The five seeds are 0 to 4.
Query selectors. Random: one target and its evidence variables are drawn uniformly for the problem, and the query is asked for the evidence values of 128 test rows. Topological (128 queries per cell): targets are allocated by structural role, 30% to hubs, 30% to cut nodes, 30% to terminals and 10% at random. Hubs are ranked by the size of their Markov blanket, that is, the set of their parents, their children and the other parents of their children. Cut nodes are the articulation points of the moral graph: the undirected graph obtained by linking the parents of every node and dropping the direction of the edges, which a cut node disconnects when it is removed. Terminals are ranked by their depth minus their number of descendants. Hubs, cut nodes and random targets are asked in the prediction or in the diagnosis direction with equal probability, and terminals in the prediction direction only. The evidence is taken along the longest path (40% of the queries), inside the Markov blanket (40%) or at random (20%). Heaviest: the top-ranked hub, cut node and terminal, each in the prediction and in the diagnosis direction and with full and with empty evidence, for at most twelve queries per cell (eight when the graph has no cut node); the evidence is taken along the longest path for hubs and terminals and inside the Markov blanket for cut nodes. In the batching scenario each of these queries is asked for the evidence values of 1024 rows.
Reference. For a discrete target the reference set has 5000 samples on synthetic networks and as many samples as the training set on real ones; a query whose evidence agrees with fewer than ten reference samples is not scored. For a continuous target the reference is a sample of 2000 draws from , obtained by likelihood weighting on the true model. Both references are finite samples, which gives the floor of Section 3. For a discrete target it comes from the few reference samples that agree with the evidence, so it varies with the network and with the query. The floor is the average error of an exact answer against the sampled reference and not a bound: an approximate method can fall slightly below the exact engines.
Learning metrics. The learning scenarios score the fitted conditionals directly, without queries. On discrete networks the metric is the parameter-recovery TV: the total variation between a learned and a true row of a CPT, averaged over the parent configurations with their true probabilities and then over the nodes. Continuous families have no common parameters to compare, since a linear-Gaussian model, an MDN and a kNN estimator do not share a parameter space, so we score the fitted density itself with the held-out negative log-likelihood (NLL) per node: minus the log-density of a test row under the fitted network, averaged over the test rows and divided by n. The NLL is a strictly proper scoring rule. Its expectation is the entropy of the true conditionals plus the Kullback–Leibler divergence from the true to the fitted model, so on the same problem the difference between two methods is a difference in divergence from the truth, and it applies to every mechanism that exposes a density. We prefer it to two alternatives. W1, the metric of the inference scenarios, compares samples of a posterior and therefore needs a query and an engine, which would mix the error of learning with the error of inference. The calibration error PIT-KS (the Kolmogorov–Smirnov distance between the probability integral transform of held-out values and the uniform distribution) needs no query, but calibration is necessary and not sufficient: a model that ignores the parents and returns the marginal of each node is perfectly calibrated. Our runs show the difference: on 50-node non-Gaussian networks with 4096 rows FlexCode has less than half the PIT-KS of the linear-Gaussian model (0.028 against 0.065, close to the 0.023 of the MDN) and the worst NLL of the three (1.42 against 1.26 and 1.20). PIT-KS is reported for every method in Appendix B.5.
Batches with empty evidence. With empty evidence (Appendix B.3) the B queries of a batch are the same marginal query, so NBN answers it once and the time per query is the time of one query divided by B; we do not count this as a batching gain.
Particles. The sampling engines of NBN use 2048 particles in the accuracy, scalability and real-network scenarios and 16 in the batching scenario, which measures time only. Pyro uses 50 particles in every scenario.
Budgets and execution. The fit budget and the query budget are 1200 s each; the query budget is 600 s in the batching scenario. The memory cap of a cell is 80% of the memory that is free on the machine when the cell starts. Each cell runs in its own process, so that a timeout or an out-of-memory failure ends that cell only.
Reporting. In the figures the error bar of a method spans the smallest and the largest value that enters its interquartile mean, and the value axes are logarithmic. Each panel has its own legend; a method has the same colour in every figure, and for NBN the colour is the mechanism and the hatch is the engine. Each panel of the main text shows all applicable external baselines plus two NBN methods, the best parametric or neural one and the best non-parametric one (the two best on discrete networks), selected once per family on the accuracy metric of the scenario. On the continuous families of the accuracy and scalability scenarios the linear-Gaussian mechanism is shown as well, so that the NBN method that reaches the largest networks is always visible. The tables of Appendix B report the IQM of the interquartile range.
Hardware. All runs use one server with an Intel Xeon E5-2640 v4 CPU at 2.40 GHz (20 cores), 126 GB of RAM and an NVIDIA Titan X (Pascal) GPU with 12 GB of memory.
B Complete results
This appendix reports every method on every scenario of Section 3, including the mechanisms and engines that the main text does not discuss (normalizing-flow, kernel-density and neural categorical conditionals, and the amortized importance-sampling engine AIS), and the fit and query times of the scenarios where the main text reports accuracy only. Methods carry the names of the configuration files, library-model-engine; for NBN the model is the mechanism of the conditionals. In the figures a bar is the interquartile mean (IQM) over the seeds a method solved and the error bar spans the smallest and the largest value that enters that mean; f/n above a bar means that f of n seeds failed, and a missing bar carries the failure status. The value axes are logarithmic. Each panel has its own legend; a method has the same colour in every figure, and for NBN the colour is the mechanism and the hatch is the engine. In the tables a cell is IQM ± half the interquartile range, followed by (f/n) when f of the n seeds failed for any reason (time budget, memory, NaN output, error); a status alone (timeout, oom, nan) means that no seed was solved, and – that the method was not run in that configuration. In each column the best method is in bold: the one with the fewest failed seeds and, among those, the best IQM. In the learning scenarios the negative log-likelihood is the mean over the held-out rows, divided by the number of nodes.
B.1 Inference accuracy
discrete



Figure 5: Inference accuracy, all methods: accuracy (TV on discrete targets, W1 on continuous ones) against network size.
discrete



Figure 6: Inference accuracy, all methods: total query time (s) against network size.
discrete



Figure 7: Inference accuracy, all methods: fit time (s) against network size.
Table 5: Inference accuracy, discrete networks: TV (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-bayes-ve | |||||
| pgmpy-mle-ve | |||||
| pomegranate-discrete-ve | timeout | timeout | |||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-cat-ais | |||||
| nbn-cat-avi | |||||
| nbn-cat-lw | |||||
| nbn-cat-ve |
Table 6: Inference accuracy, discrete networks: total query time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-bayes-ve | |||||
| pgmpy-mle-ve | |||||
| pomegranate-discrete-ve | timeout | timeout | |||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-cat-ais | |||||
| nbn-cat-avi | |||||
| nbn-cat-lw | |||||
| nbn-cat-ve |
Table 7: Inference accuracy, discrete networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-bayes-ve | |||||
| pgmpy-mle-ve | |||||
| pomegranate-discrete-ve | timeout | timeout | |||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-cat-ais | |||||
| nbn-cat-avi | |||||
| nbn-cat-lw | |||||
| nbn-cat-ve |
Table 8: Inference accuracy, linear-Gaussian networks: W1 (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | timeout | ||
| nbn-flow-avi | timeout | timeout | timeout | ||
| nbn-flow-lw | timeout | timeout | timeout | ||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
Table 9: Inference accuracy, linear-Gaussian networks: total query time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | timeout | ||
| nbn-flow-avi | timeout | timeout | timeout | ||
| nbn-flow-lw | timeout | timeout | timeout | ||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
Table 10: Inference accuracy, linear-Gaussian networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | timeout | ||
| nbn-flow-avi | timeout | timeout | timeout | ||
| nbn-flow-lw | timeout | timeout | timeout | ||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
Table 11: Inference accuracy, non-Gaussian networks: W1 (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | |||
| nbn-flow-avi | timeout | timeout | |||
| nbn-flow-lw | timeout | timeout | |||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
Table 12: Inference accuracy, non-Gaussian networks: total query time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | |||
| nbn-flow-avi | timeout | timeout | |||
| nbn-flow-lw | timeout | timeout | |||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
Table 13: Inference accuracy, non-Gaussian networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg-predict | |||||
| pyro-empirical-importance | timeout | timeout | |||
| nbn-flexcode-lw | timeout | timeout | |||
| nbn-flow-ais | timeout | timeout | |||
| nbn-flow-avi | timeout | timeout | |||
| nbn-flow-lw | timeout | timeout | |||
| nbn-kde-lw | oom | oom | oom | oom | |
| nbn-knn-lw | oom | oom | |||
| nbn-lg-ais | |||||
| nbn-lg-avi | |||||
| nbn-lg-lw | |||||
| nbn-mdn-ais | timeout | timeout | |||
| nbn-mdn-avi | timeout | timeout | |||
| nbn-mdn-lw | timeout | timeout |
B.2 Scalability
discrete



Figure 8: Scalability, all methods: accuracy (TV on discrete targets, W1 on continuous ones) against network size.
discrete



Figure 9: Scalability, all methods: accuracy with full evidence against network size.
discrete



Figure 10: Scalability, all methods: time per query (s), both evidence modes against network size.
discrete



Figure 11: Scalability, all methods: time per query (s), full evidence against network size.
Table 14: Scalability, discrete networks: TV (lower is better), both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | ||||
| pgmpy-mle-ve | ||||
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | timeout | |||
| nbn-cat-ais | oom | |||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 15: Scalability, discrete networks: TV (lower is better), full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | ||||
| pgmpy-mle-ve | ||||
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | ||||
| nbn-cat-ais | oom | |||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 16: Scalability, discrete networks: time per query in seconds, both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | ||||
| pgmpy-mle-ve | ||||
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | timeout | |||
| nbn-cat-ais | oom | |||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 17: Scalability, discrete networks: time per query in seconds, full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | ||||
| pgmpy-mle-ve | ||||
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | ||||
| nbn-cat-ais | oom | |||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 18: Scalability, linear-Gaussian networks: W1 (lower is better), both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nbn-flexcode-lw | timeout | timeout | ||
| nbn-flow-ais | timeout | timeout | timeout | |
| nbn-flow-avi | timeout | timeout | timeout | |
| nbn-flow-lw | timeout | timeout | timeout | |
| nbn-kde-lw | oom | oom | oom | |
| nbn-knn-lw | oom | oom | ||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | timeout | ||
| nbn-mdn-avi | timeout | timeout | ||
| nbn-mdn-lw | timeout | timeout |
Table 19: Scalability, linear-Gaussian networks: W1 (lower is better), full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | timeout | |
| nnbn-flow-avi | timeout | timeout | timeout | |
| nnbn-flow-lw | timeout | timeout | timeout | |
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 20: Scalability, linear-Gaussian networks: time per query in seconds, both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nnbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | timeout | |
| nnbn-flow-avi | timeout | timeout | timeout | |
| nnbn-flow-lw | timeout | timeout | timeout | |
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 21: Scalability, linear-Gaussian networks: time per query in seconds, full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nnbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | timeout | |
| nnbn-flow-avi | timeout | timeout | timeout | |
| nnbn-flow-lw | timeout | timeout | timeout | |
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 22: Scalability, non-Gaussian networks: W1 (lower is better), both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | ||
| nnbn-flow-avi | timeout | timeout | ||
| nnbn-flow-lw | timeout | timeout | ||
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 23: Scalability, non-Gaussian networks: W1 (lower is better), full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nnbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | ||
| nnbn-flow-avi | timeout | timeout | ||
| nnbn-flow-lw | timeout | timeout | ||
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 24: Scalability, non-Gaussian networks: time per query in seconds, both evidence modes, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nnbn-flexcode-lw | timeout | timeout | ||
| nnbn-flow-ais | timeout | timeout | ||
| nnbn-flow-avi | timeout | timeout | ||
| nnbn-flow-lw | timeout | timeout | ||
| nnbn-kde-lw | oom | oom | oom | |
| nnbn-knn-lw | oom | oom | ||
| nnbn-lg-ais | ||||
| nnbn-lg-avi | ||||
| nnbn-lg-lw | ||||
| nnbn-mdn-ais | timeout | timeout | ||
| nnbn-mdn-avi | timeout | timeout | ||
| nnbn-mdn-lw | timeout | timeout |
Table 25: Scalability, non-Gaussian networks: time per query in seconds, full evidence, against network size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | ||||
| pyro-empirical-importance | ||||
| nbn-flexcode-lw | timeout | timeout | ||
| nbn-flow-ais | timeout | timeout | ||
| nbn-flow-avi | timeout | timeout | ||
| nbn-flow-lw | timeout | timeout | ||
| nbn-kde-lw | oom | oom | oom | |
| nbn-knn-lw | oom | oom | ||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | timeout | ||
| nbn-mdn-avi | timeout | timeout | ||
| nbn-mdn-lw | timeout | timeout |
B.3 Batched queries
discrete

B (queries per batch)
continuous (Gaussian)

B (queries per batch)
continuous (non-Gaussian)

B (queries per batch)
Figure 12: Batched queries, all methods: time per query (s), full evidence against query batch size B.
discrete

B (queries per batch)
continuous (Gaussian)

B (queries per batch)
continuous (non-Gaussian)

B (queries per batch)
Figure 13: Batched queries, all methods: time per query (s), empty evidence against query batch size B.
Table 26: Batched queries, discrete networks: time per query in seconds, full evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | - | - | - | |
| pgmpy-mle-ve | - | - | - | |
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | timeout | - | - | - |
| nbn-cat-ais | ||||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 27: Batched queries, discrete networks: time per query in seconds, empty evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes-ve | - | - | - | |
| pgmpy-mle-ve | - | - | - | |
| pomegranate-discrete-ve | timeout | |||
| pyro-empirical-importance | timeout | - | - | - |
| nbn-cat-ais | ||||
| nbn-cat-avi | ||||
| nbn-cat-lw | ||||
| nbn-cat-ve |
Table 28: Batched queries, linear-Gaussian networks: time per query in seconds, full evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | - | - | - | |
| pyro-empirical-importance | timeout | - | - | - |
| nbn-flexcode-lw | ||||
| nbn-flow-ais | timeout | |||
| nbn-flow-avi | timeout | |||
| nbn-flow-lw | timeout | |||
| nbn-kde-lw | ||||
| nbn-knn-lw | ||||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | |||
| nbn-mdn-avi | ||||
| nbn-mdn-lw |
Table 29: Batched queries, linear-Gaussian networks: time per query in seconds, empty evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | - | - | - | |
| pyro-empirical-importance | timeout | - | - | - |
| nbn-flexcode-lw | ||||
| nbn-flow-ais | timeout | |||
| nbn-flow-avi | timeout | |||
| nbn-flow-lw | timeout | |||
| nbn-kde-lw | ||||
| nbn-knn-lw | ||||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | |||
| nbn-mdn-avi | ||||
| nbn-mdn-lw |
Table 30: Batched queries, non-Gaussian networks: time per query in seconds, full evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | - | - | - | |
| pyro-empirical-importance | timeout | - | - | - |
| nbn-flexcode-lw | ||||
| nbn-flow-ais | timeout | |||
| nbn-flow-avi | timeout | |||
| nbn-flow-lw | timeout | |||
| nbn-kde-lw | ||||
| nbn-knn-lw | ||||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | |||
| nbn-mdn-avi | ||||
| nbn-mdn-lw |
Table 31: Batched queries, non-Gaussian networks: time per query in seconds, empty evidence, against query batch size .
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg-predict | - | - | - | |
| pyro-empirical-importance | timeout | - | - | - |
| nbn-flexcode-lw | ||||
| nbn-flow-ais | timeout | |||
| nbn-flow-avi | timeout | |||
| nbn-flow-lw | timeout | |||
| nbn-kde-lw | ||||
| nbn-knn-lw | ||||
| nbn-lg-ais | ||||
| nbn-lg-avi | ||||
| nbn-lg-lw | ||||
| nbn-mdn-ais | timeout | |||
| nbn-mdn-avi | ||||
| nbn-mdn-lw |
B.4 Real networks
discrete

Gaussian

CLG

Figure 14: Real networks, all methods: accuracy (TV on discrete targets, W1 on continuous ones) against network.
discrete

Gaussian

CLG

Figure 15: Real networks, all methods: total query time (s) against network.
Table 32: Real networks, discrete networks: TV (lower is better), against network.
| Method | asia | sachs | mildew | barley | hailfinder | diabetes | link | munin |
|---|---|---|---|---|---|---|---|---|
| pgmpy-bayes-ve | (1/5) | |||||||
| pgmpy-mle-ve | (1/5) | |||||||
| pomegranate-discrete-ve | timeout | timeout | ||||||
| pyro-empirical-importance | timeout | timeout | timeout | |||||
| nbn-cat-ais | ||||||||
| nbn-cat-avi | ||||||||
| nbn-cat-lw | ||||||||
| nbn-cat-ve |
Table 33: Real networks, discrete networks: total query time in seconds, against network.
| Method | asia | sachs | mildew | barley | hailfinder | diabetes | link | munin |
|---|---|---|---|---|---|---|---|---|
| pgmpy-bayes-ve | (1/5) | |||||||
| pgmpy-mle-ve | (1/5) | |||||||
| pomegranate-discrete-ve | timeout | timeout | ||||||
| pyro-empirical-importance | timeout | timeout | timeout | |||||
| nbn-cat-ais | ||||||||
| nbn-cat-avi | ||||||||
| nbn-cat-lw | ||||||||
| nbn-cat-ve |
Table 34: Real networks, Gaussian networks: W1 (lower is better), against network.
| Method | ecoli70 | arth150 |
|---|---|---|
| pgmpy-lg-predict | ||
| pyro-empirical-importance | ||
| nbn-flexcode-lw | ||
| nbn-flow-ais | ||
| nbn-flow-avi | ||
| nbn-flow-lw | ||
| nbn-kde-lw | ||
| nbn-knn-lw | ||
| nbn-lg-ais | ||
| nbn-lg-avi | ||
| nbn-lg-lw | ||
| nbn-mdn-ais | ||
| nbn-mdn-avi | ||
| nbn-mdn-lw |
Table 35: Real networks, Gaussian networks: total query time in seconds, against network.
| Method | ecoli70 | arth150 |
|---|---|---|
| pgmpy-lg-predict | ||
| pyro-empirical-importance | ||
| nbn-flexcode-lw | ||
| nbn-flow-ais | ||
| nbn-flow-avi | ||
| nbn-flow-lw | ||
| nbn-kde-lw | ||
| nbn-knn-lw | ||
| nbn-lg-ais | ||
| nbn-lg-avi | ||
| nbn-lg-lw | ||
| nbn-mdn-ais | ||
| nbn-mdn-avi | ||
| nbn-mdn-lw |
Table 36: Real networks, CLG networks: W1 (lower is better), against network.
| Method | healthcare | sangiovese | mehra |
|---|---|---|---|
| pyro-empirical-importance | |||
| nbn-flexcode-lw | |||
| nbn-flow-ais | |||
| nbn-flow-avi | |||
| nbn-flow-lw | |||
| nbn-kde-lw | oom | ||
| nbn-knn-lw | |||
| nbn-mdn-ais | |||
| nbn-mdn-avi | |||
| nbn-mdn-lw |
Table 37: Real networks, CLG networks: total query time in seconds, against network.
| Method | healthcare | sangiovese | mehra |
|---|---|---|---|
| pyro-empirical-importance | |||
| nbn-flexcode-lw | |||
| nbn-flow-ais | |||
| nbn-flow-avi | |||
| nbn-flow-lw | |||
| nbn-kde-lw | oom | ||
| nbn-knn-lw | |||
| nbn-mdn-ais | |||
| nbn-mdn-avi | |||
| nbn-mdn-lw |
B.5 Parameter learning
discrete

Figure 16: Parameter learning, all methods: parameter-recovery TV against network size.
continuous (Gaussian)


Figure 17: Parameter learning, all methods: calibration error (PIT-KS) against network size.
Giovanni Briglia , Marco Lippi, Stefano Mariani, and Franco Zambonelli
discrete



Figure 18: Parameter learning, all methods: held-out negative log-likelihood per node against network size.
discrete



Figure 19: Parameter learning, all methods: fit time (s) against network size.
Table 38: Parameter learning, discrete networks: parameter-recovery TV (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-bayes | |||||
| pgmpy-mle | |||||
| pomegranate-discrete-ve | |||||
| pyro-empirical | |||||
| nbn-cat | |||||
| nbn-cat-bayes |
Table 39: Parameter learning, discrete networks: held-out negative log-likelihood per node (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| nbn-cat | |||||
| nbn-cat-bayes |
Table 40: Parameter learning, discrete networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-bayes | |||||
| pgmpy-mle | |||||
| pomegranate-discrete-ve | |||||
| pyro-empirical | |||||
| nbn-cat | |||||
| nbn-cat-bayes |
Table 41: Parameter learning, linear-Gaussian networks: PIT-KS (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | (3/5) | timeout | timeout | ||
| nbn-kde | (1/5) | (2/5) | (2/5) | (1/5) | oom |
| nbn-knn | oom | oom | |||
| nbn-lg | |||||
| nbn-mdn | timeout | timeout | timeout |
Table 42: Parameter learning, linear-Gaussian networks: held-out negative log-likelihood per node (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | (3/5) | timeout | timeout | ||
| nbn-kde | (1/5) | (2/5) | (2/5) | (1/5) | oom |
| nbn-knn | oom | oom | |||
| nbn-lg | |||||
| nbn-mdn | timeout | timeout | timeout |
Table 43: Parameter learning, linear-Gaussian networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-lg | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | (3/5) | timeout | timeout | ||
| nbn-kde | (1/5) | (2/5) | (2/5) | (1/5) | oom |
| nbn-knn | oom | oom | |||
| nbn-lg | |||||
| nbn-mdn | timeout | timeout | timeout |
Table 44: Parameter learning, non-Gaussian networks: PIT-KS (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-1g | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | timeout | timeout | |||
| nbn-kde | oom | oom | |||
| nbn-knn | oom | oom | |||
| nbn-1g | |||||
| nbn-mdn | timeout | timeout | timeout |
Table 45: Parameter learning, non-Gaussian networks: held-out negative log-likelihood per node (lower is better), against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-1g | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | timeout | timeout | |||
| nbn-kde | oom | oom | |||
| nbn-knn | oom | oom | |||
| nbn-1g | |||||
| nbn-mdn | timeout | timeout | timeout |
Table 46: Parameter learning, non-Gaussian networks: fit time in seconds, against network size.
| Method | |||||
|---|---|---|---|---|---|
| pgmpy-1g | |||||
| nbn-flexcode | timeout | timeout | |||
| nbn-flow | timeout | timeout | |||
| nbn-kde | oom | oom | |||
| nbn-knn | oom | oom | |||
| nbn-1g | |||||
| nbn-mdn | timeout | timeout | timeout |
B.6 Sample efficiency
discrete

Figure 20: Sample efficiency, all methods: parameter-recovery TV against training-set size.
continuous (Gaussian)

continuous (non-Gaussian)

Figure 21: Sample efficiency, all methods: calibration error (PIT-KS) against training-set size.
discrete

continuous (Gaussian)

continuous (non-Gaussian)

Figure 22: Sample efficiency, all methods: held-out negative log-likelihood per node against training-set size.
discrete


Figure 23: Sample efficiency, all methods: fit time (s) against training-set size.
Table 47: Sample efficiency, discrete networks: parameter-recovery TV (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes | ||||
| pgmpy-mle | ||||
| pomegranate-discrete-ve | ||||
| pyro-empirical | ||||
| nbn-cat | ||||
| nbn-cat-bayes |
Table 48: Sample efficiency, discrete networks: held-out negative log-likelihood per node (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| nbn-cat | ||||
| nbn-cat-bayes |
Table 49: Sample efficiency, discrete networks: fit time in seconds, against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-bayes | ||||
| pgmpy-mle | ||||
| pomegranate-discrete-ve | ||||
| pyro-empirical | ||||
| nbn-cat | ||||
| nbn-cat-bayes |
Table 50: Sample efficiency, linear-Gaussian networks: PIT-KS (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | ||||
| nbn-knn | ||||
| nbn-lg | ||||
| nbn-mdn | timeout |
Table 51: Sample efficiency, linear-Gaussian networks: held-out negative log-likelihood per node (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | ||||
| nbn-knn | ||||
| nbn-lg | ||||
| nbn-mdn | timeout |
Table 52: Sample efficiency, linear-Gaussian networks: fit time in seconds, against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-lg | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | ||||
| nbn-knn | ||||
| nbn-lg | ||||
| nbn-mdn | timeout |
Table 53: Sample efficiency, non-Gaussian networks: PIT-KS (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-1g | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | oom | oom | ||
| nbn-knn | ||||
| nbn-1g | ||||
| nbn-mdn | timeout |
Table 54: Sample efficiency, non-Gaussian networks: held-out negative log-likelihood per node (lower is better), against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-1g | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | oom | oom | ||
| nbn-knn | ||||
| nbn-1g | ||||
| nbn-mdn | timeout |
Table 55: Sample efficiency, non-Gaussian networks: fit time in seconds, against training-set size.
| Method | ||||
|---|---|---|---|---|
| pgmpy-1g | ||||
| nbn-flexcode | timeout | |||
| nbn-flow | timeout | |||
| nbn-kde | oom | oom | ||
| nbn-knn | ||||
| nbn-1g | ||||
| nbn-mdn | timeout |