logo Netzschleuder network catalog, repository, and centrifuge

History of bnlearn

The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.

[entries] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto beff7c9
The dates are those of the commits that first added the entries' files
(2020-08-11 for the entries of the initial commit); renamed entries keep
the date of their first name.

Changed: none
diff --git a/entries/bnlearn/__init__.py b/entries/bnlearn/__init__.py
index 0c859f7..11ce150 100644
--- a/entries/bnlearn/__init__.py
+++ b/entries/bnlearn/__init__.py
@@ -67,15 +67,7 @@ citation = [('M. Scutari, "Learning Bayesian Networks with the bnlearn R Package
             ('C. S. Jensen, A. Kong, "Blocking Gibbs Sampling for Linkage Analysis in Large Pedigrees with Many Loops." The American Journal of Human Genetics 65(3), 885-901 (1999)', 'https://doi.org/10.1086/302524'),
             ('S. Andreassen, F. V. Jensen, S. K. Andersen, B. Falck, U. Kjærulff, M. Woldbye, A. R. Sørensen, A. Rosenfalck, F. Jensen, "MUNIN - an Expert EMG Assistant." In Computer-Aided Electromyography and Expert Systems, Chapter 21, Elsevier (1989)', 'https://www.bnlearn.com/bnrepository/discrete-massive.html#munin'),
             ('D. Heckerman, E. Horvitz, B. Nathwani, "Toward Normative Expert Systems: Part I The Pathfinder Project." Methods of Information in Medicine 31(2), 90-105 (1992)', 'https://doi.org/10.1055/s-0038-1634867')]
-icon_hash = ['57242eb1461efe0c7a675e54', '57242fee461efe0c7a675e56',
-             '5724315e461efe0c7a675e59', '57243343461efe0c7a675e5b',
-             '57243462461efe0c7a675e5d', '5724351d461efe0c7a675e5f',
-             '572435d3461efe0c7a675e61', '57243736461efe0c7a675e68',
-             '57243812461efe0c7a675e6a', '57243906461efe0c7a675e6c',
-             '5724397c461efe0c7a675e6e', '57243a3f461efe0c7a675e70',
-             '57243b18461efe0c7a675e72', '57243b66461efe0c7a675e74',
-             '57243c0e461efe0c7a675e76', '57243cec461efe0c7a675e78',
-             '57243d3c461efe0c7a675e7a']
+date_added = '2026-10-25'
 upstream_license = None
 upstream_prefix = 'https://www.bnlearn.com/bnrepository'
 
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto bc3dbbd
The lists of properties at the end of the descriptions marked edge
properties with "Edge" but left node properties unmarked, or grouped
them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property
was often unclear. Every item now starts with (Node), (Edge) or (Graph),
followed by the property names, a colon and the explanation, one item
per property or group of properties; qualifications (kinds of nodes,
networks) follow the names in parentheses. Properties that were only
named got a short explanation, and a few items that named the wrong
kind of property were corrected.
diff --git a/entries/bnlearn/__init__.py b/entries/bnlearn/__init__.py
index 80fa0e0..0c859f7 100644
--- a/entries/bnlearn/__init__.py
+++ b/entries/bnlearn/__init__.py
@@ -46,7 +46,9 @@ The networks are:
 
 The networks have the following properties:
 
-- Nodes: `name`, the name of the variable; `n_states`, the number of values (states) the discrete variable can take; `states`, the names of the states."""
+- (Node) `name`: the name of the variable.
+- (Node) `n_states`: the number of values (states) the discrete variable can take.
+- (Node) `states`: the names of the states."""
 tags = ['Informational', 'Unweighted', 'Metadata']
 url = 'https://www.bnlearn.com/bnrepository/'
 citation = [('M. Scutari, "Learning Bayesian Networks with the bnlearn R Package." Journal of Statistical Software 35(3), 1-22 (2010)', 'https://doi.org/10.18637/jss.v035.i03'),
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 2c69f19
Unneeded "global files" statements, unused imports and variables,
f-strings without placeholders, duplicate keys in foodweb_little_rock
(keeping the order and the values used), and the second definition of
get_lines() in twitter_higgs. Nothing changes in the networks or
descriptions.

Changed: none
diff --git a/entries/bnlearn/__init__.py b/entries/bnlearn/__init__.py
index c1a7d3a..80fa0e0 100644
--- a/entries/bnlearn/__init__.py
+++ b/entries/bnlearn/__init__.py
@@ -107,7 +107,6 @@ def read_bif(f):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fname, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] New entry: bnlearn by Tiago de Paula Peixoto 11acac5
diff --git a/entries/bnlearn/__init__.py b/entries/bnlearn/__init__.py
new file mode 100644
index 0000000..c1a7d3a
--- /dev/null
+++ b/entries/bnlearn/__init__.py
@@ -0,0 +1,124 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import re
+from .. import *
+
+title = "bnlearn Bayesian network repository (1988-2005)"
+description = """Directed acyclic graphs of reference (discrete) Bayesian networks commonly used as benchmarks for Bayesian network learning and inference, as collected in the Bayesian Network Repository of the bnlearn R package by M. Scutari. Most of these networks were constructed by domain experts as probabilistic expert systems, and many were previously distributed by the Bayesian Network Repository of the Hebrew University of Jerusalem. Nodes are random variables, and a directed edge from A to B means that A is a parent of B, i.e. that the probability distribution of B is specified conditionally on A. The networks in bnlearn have been checked and fixed where needed (e.g. so that the conditional probability tables sum to one, and without dummy single-state nodes or dependencies on nonexistent nodes), so their sizes may differ from other versions of the same networks.
+
+The networks are:
+
+- `asia`: a small fictitious model relating lung diseases, visits to Asia, smoking, X-ray results and dyspnoea (Lauritzen and Spiegelhalter, 1988).
+- `cancer` and `earthquake`: small textbook examples from Korb and Nicholson, "Bayesian Artificial Intelligence" (2010).
+- `sachs`: a causal protein-signaling network in human immune system cells, inferred from flow cytometry data (Sachs et al., 2005).
+- `survey`: a textbook example on the usage of different means of transport, from Scutari and Denis, "Bayesian Networks: with Examples in R" (2021).
+- `alarm`: the ALARM (A Logical Alarm Reduction Mechanism) system for patient monitoring in intensive care (Beinlich et al., 1989).
+- `barley`: a preliminary model for a decision support system for growing malting barley without pesticides (Kristensen and Rasmussen, 2002).
+- `child`: a diagnostic system for congenital heart disease in newborn babies ("blue babies") (Spiegelhalter and Cowell, 1992).
+- `insurance`: a network for estimating the expected claim costs of car insurance policyholders (Binder et al., 1997).
+- `mildew`: a model for the management of mildew in winter wheat (Jensen and Jensen, 1996).
+- `water`: an expert system for the control of waste water treatment (Jensen et al., 1989).
+- `hailfinder`: a system for forecasting severe weather in northeastern Colorado (Abramson et al., 1996).
+- `hepar2`: a system for diagnosis of liver disorders (Onisko, 2003).
+- `win95pts`: a system for troubleshooting printing problems in Microsoft Windows 95.
+- `andes`: a model of a student's knowledge in the ANDES intelligent tutoring system for Newtonian physics (Conati et al., 1997).
+- `diabetes`: a model of carbohydrate metabolism used for insulin dose adjustment (Andreassen et al., 1991).
+- `link`: a model for linkage analysis in genetics, over a large pedigree (Jensen and Kong, 1999).
+- `munin`, `munin1`, `munin2`, `munin3`, `munin4`: the MUNIN expert system for electromyography (Andreassen et al., 1989), as the full network and four subnetworks.
+- `pathfinder`: the PATHFINDER expert system for the diagnosis of lymph-node diseases (Heckerman et al., 1992).
+- `pigs`: a pedigree model for the breeding of pigs.
+
+The networks have the following properties:
+
+- Nodes: `name`, the name of the variable; `n_states`, the number of values (states) the discrete variable can take; `states`, the names of the states."""
+tags = ['Informational', 'Unweighted', 'Metadata']
+url = 'https://www.bnlearn.com/bnrepository/'
+citation = [('M. Scutari, "Learning Bayesian Networks with the bnlearn R Package." Journal of Statistical Software 35(3), 1-22 (2010)', 'https://doi.org/10.18637/jss.v035.i03'),
+            ('S. Lauritzen, D. Spiegelhalter, "Local Computations with Probabilities on Graphical Structures and Their Application to Expert Systems." Journal of the Royal Statistical Society: Series B 50(2), 157-194 (1988)', 'https://doi.org/10.1111/j.2517-6161.1988.tb01721.x'),
+            ('K. Sachs, O. Perez, D. Pe\'er, D. A. Lauffenburger, G. P. Nolan, "Causal Protein-Signaling Networks Derived from Multiparameter Single-Cell Data." Science 308, 523-529 (2005)', 'https://doi.org/10.1126/science.1105809'),
+            ('I. A. Beinlich, H. J. Suermondt, R. M. Chavez, G. F. Cooper, "The ALARM Monitoring System: A Case Study with two Probabilistic Inference Techniques for Belief Networks." AIME 89, Lecture Notes in Medical Informatics 38, 247-256 (1989)', 'https://doi.org/10.1007/978-3-642-93437-7_28'),
+            ('K. Kristensen, I. A. Rasmussen, "The use of a Bayesian network in the design of a decision support system for growing malting barley without use of pesticides." Computers and Electronics in Agriculture 33(3), 197-217 (2002)', 'https://doi.org/10.1016/S0168-1699(02)00007-8'),
+            ('D. J. Spiegelhalter, R. G. Cowell, "Learning in probabilistic expert systems." In Bayesian Statistics 4, 447-466, Clarendon Press (1992)', 'https://www.bnlearn.com/bnrepository/discrete-medium.html#child'),
+            ('J. Binder, D. Koller, S. Russell, K. Kanazawa, "Adaptive Probabilistic Networks with Hidden Variables." Machine Learning 29, 213-244 (1997)', 'https://doi.org/10.1023/A:1007421730016'),
+            ('A. L. Jensen, F. V. Jensen, "MIDAS - An Influence Diagram for Management of Mildew in Winter Wheat." Proceedings of the Twelfth Conference on Uncertainty in Artificial Intelligence (UAI 1996), 349-356 (1996)', 'https://arxiv.org/abs/1302.3587'),
+            ('F. V. Jensen, U. Kjærulff, K. G. Olesen, J. Pedersen, "Et Forprojekt Til et Ekspertsystem for Drift af Spildevandsrensning (An Expert System for Control of Waste Water Treatment - A Pilot Project)." Technical Report, Judex Datasystemer A/S, Aalborg (1989)', 'https://www.bnlearn.com/bnrepository/discrete-medium.html#water'),
+            ('B. Abramson, J. Brown, W. Edwards, A. Murphy, R. L. Winkler, "Hailfinder: A Bayesian system for forecasting severe weather." International Journal of Forecasting 12(1), 57-71 (1996)', 'https://doi.org/10.1016/0169-2070(95)00664-8'),
+            ('A. Onisko, "Probabilistic Causal Models in Medicine: Application to Diagnosis of Liver Disorders." Ph.D. Dissertation, Institute of Biocybernetics and Biomedical Engineering, Polish Academy of Science, Warsaw (2003)', 'https://www.bnlearn.com/bnrepository/discrete-large.html#hepar2'),
+            ('C. Conati, A. S. Gertner, K. VanLehn, M. J. Druzdzel, "On-Line Student Modeling for Coached Problem Solving Using Bayesian Networks." User Modeling, 231-242 (1997)', 'https://doi.org/10.1007/978-3-7091-2670-7_24'),
+            ('S. Andreassen, R. Hovorka, J. Benn, K. G. Olesen, E. R. Carson, "A Model-Based Approach to Insulin Adjustment." AIME 91, Lecture Notes in Medical Informatics 44, 239-248 (1991)', 'https://doi.org/10.1007/978-3-642-48650-0_19'),
+            ('C. S. Jensen, A. Kong, "Blocking Gibbs Sampling for Linkage Analysis in Large Pedigrees with Many Loops." The American Journal of Human Genetics 65(3), 885-901 (1999)', 'https://doi.org/10.1086/302524'),
+            ('S. Andreassen, F. V. Jensen, S. K. Andersen, B. Falck, U. Kjærulff, M. Woldbye, A. R. Sørensen, A. Rosenfalck, F. Jensen, "MUNIN - an Expert EMG Assistant." In Computer-Aided Electromyography and Expert Systems, Chapter 21, Elsevier (1989)', 'https://www.bnlearn.com/bnrepository/discrete-massive.html#munin'),
+            ('D. Heckerman, E. Horvitz, B. Nathwani, "Toward Normative Expert Systems: Part I The Pathfinder Project." Methods of Information in Medicine 31(2), 90-105 (1992)', 'https://doi.org/10.1055/s-0038-1634867')]
+icon_hash = ['57242eb1461efe0c7a675e54', '57242fee461efe0c7a675e56',
+             '5724315e461efe0c7a675e59', '57243343461efe0c7a675e5b',
+             '57243462461efe0c7a675e5d', '5724351d461efe0c7a675e5f',
+             '572435d3461efe0c7a675e61', '57243736461efe0c7a675e68',
+             '57243812461efe0c7a675e6a', '57243906461efe0c7a675e6c',
+             '5724397c461efe0c7a675e6e', '57243a3f461efe0c7a675e70',
+             '57243b18461efe0c7a675e72', '57243b66461efe0c7a675e74',
+             '57243c0e461efe0c7a675e76', '57243cec461efe0c7a675e78',
+             '57243d3c461efe0c7a675e7a']
+upstream_license = None
+upstream_prefix = 'https://www.bnlearn.com/bnrepository'
+
+nets = ["asia", "cancer", "earthquake", "sachs", "survey", "alarm", "barley",
+        "child", "insurance", "mildew", "water", "hailfinder", "hepar2",
+        "win95pts", "andes", "diabetes", "link", "pathfinder", "pigs", "munin"]
+files = [(f"{n}/{n}.bif.gz", n, "bif") for n in nets] + \
+    [(f"munin4/munin{i}.bif.gz", f"munin{i}", "bif") for i in range(1, 5)]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+def read_bif(f):
+    "Return the variables (name -> list of states) and arcs of a BIF file."
+    text = f.read()
+    variables = {}
+    for m in re.finditer(r"variable\s+(\S+)\s*\{\s*type\s+discrete\s*\[\s*(\d+)\s*\]\s*\{([^}]*)\}",
+                         text):
+        states = [s.strip() for s in m.group(3).split(",")]
+        assert len(states) == int(m.group(2))
+        variables[m.group(1)] = states
+    arcs = []
+    for m in re.finditer(r"probability\s*\(\s*([^)|]+?)\s*(?:\|\s*([^)]*))?\)", text):
+        child = m.group(1).strip()
+        parents = [p.strip() for p in m.group(2).split(",")] if m.group(2) else []
+        arcs.extend((p, child) for p in parents)
+    return variables, arcs
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fname, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        with open_upstream_file(name, fname, "r") as f:
+            variables, arcs = read_bif(f)
+        idx = {v: i for i, v in enumerate(variables)}
+        g = Graph(directed=True)
+        g.add_vertex(len(variables))
+        g.vp.name = g.new_vp("string", vals=list(variables.keys()))
+        g.vp.n_states = g.new_vp("int", vals=[len(s) for s in variables.values()])
+        g.vp.states = g.new_vp("vector<string>", vals=list(variables.values()))
+        g.add_edge_list([(idx[s], idx[t]) for s, t in arcs])
+        yield alt, g