Registry / ai-ml / pyagrum-nightly

pyagrum-nightly

JSON →
library2.3.2.9.dev202606151779285115pypypi✓ verified 87d ago

pyAgrum-nightly is a Python wrapper for the scientific C++ aGrUM library, providing a high-level interface for Bayesian networks, Markov Networks, Influence Diagrams, and other Probabilistic Graphical Models. As a nightly build, it offers the latest features and bug fixes from the development branch. It is actively maintained with frequent updates reflecting ongoing development.

pip install pyAgrum-nightly
INSTALL
IMPORT
SIG · PYAGRUM-NIGHTLY
P
pyagrum-nightly
ai-mlpythonv2.3.2.9.dev202606151779285115
Install
13.8s avg
Import
Disk
349MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.2.9.dev202606151779285115 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 13.8s · import 0.000s · 371MB
349MB installed
● package 349MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyagrum
import pyagrum as gum
import pyAgrum as gum
Since pyAgrum 2.0.0, the package name follows PEP8 rules and is lowercase. Using 'pyAgrum' will result in an ImportError.

This quickstart demonstrates how to create a simple Bayesian network (the 'Water Sprinkler' example), define its topology and conditional probability tables, and perform inference with evidence. It highlights the use of `pyagrum` (lowercase) for imports and dictionary-based CPT assignments.

import pyagrum as gum # Create a Bayesian Network bn = gum.BayesNet("WaterSprinkler") # Add variables id_c = bn.add(gum.LabelizedVariable("c", "cloudy ?", 2)) id_s = bn.add(gum.LabelizedVariable("s", "sprinkler ?", 2)) id_r = bn.add(gum.LabelizedVariable("r", "rain ?", 2)) id_w = bn.add(gum.LabelizedVariable("w", "wet grass ?", 2)) # Add arcs (dependencies) bn.addArc(id_c, id_s) bn.addArc(id_c, id_r) bn.addArc(id_s, id_w) bn.addArc(id_r, id_w) # Define Conditional Probability Tables (CPTs) using dictionaries bn.cpt("c").fillWith([0.5, 0.5]) bn.cpt("s")[{"c": 0}] = [0.5, 0.5] bn.cpt("s")[{"c": 1}] = [0.9, 0.1] bn.cpt("r")[{"c": 0}] = [0.8, 0.2] bn.cpt("r")[{"c": 1}] = [0.2, 0.8] bn.cpt("w")[{"s": 0, "r": 0}] = [1, 0] bn.cpt("w")[{"s": 0, "r": 1}] = [0.1, 0.9] bn.cpt("w")[{"s": 1, "r": 0}] = [0.1, 0.9] bn.cpt("w")[{"s": 1, "r": 1}] = [0.01, 0.99] # Perform inference ie = gum.LazyPropagation(bn) ie.setEvidence({"w": 1}) # Wet grass is true ie.makeInference() # Get posterior probabilities posterior_c = ie.posterior("c") print(f"P(c|w=1): {posterior_c}")
Debug
Known issues
breakingThe main package import name changed from `pyAgrum` to `pyagrum` (all lowercase) starting from version 2.0.0. Older code using `import pyAgrum as gum` will fail.
fix
Update all `import pyAgrum` statements to `import pyagrum`.
affects: >=2.0.0
gotchaWhen defining Conditional Probability Tables (CPTs), especially for complex networks, directly assigning values can lead to indexing errors. pyAgrum recommends using dictionaries for clarity and to prevent common mistakes when introducing data.
fix
Always use dictionary-based assignments for CPTs (e.g., `bn.cpt("s")[{"c": 0}] = [0.5, 0.5]`) instead of direct list assignment, unless you are absolutely sure of the indexing order.
affects: All
Errors
Common errors & fixes
IOError: [pyAgrum] I/O Error: Stream states flags are not all unset
This error often occurs when attempting to save a Bayesian network or other graphical model to a file, but the specified output directory does not exist.
fix
Ensure that the directory path provided to save functions (e.g., `gum.saveBN(bn, 'path/to/directory/filename.bif')`) exists before calling the function. Create the directory if it doesn't exist.
DatabaseError: [pyAgrum] Database error: The conditioning set <COL=0, RA=4, INC=0> for target node PARTNER never appears in the database.
This error typically arises during Bayesian network learning or inference when using data, especially with small datasets or specific data splits, where a particular combination of variable values (a 'conditioning set') exists in the query/test set but was never observed in the training data.
fix
Consider using 'smoothing' or adding 'priors' during the learning phase (e.g., using `BNLearner.useAprioriSmoothing()`) to handle unseen combinations. Also, evaluate the representativeness of your dataset and data splitting strategy.
Upgrade
Version history
2.3.2.9.dev202606151779285115latest on PyPI · released Jun 15, 2026
Audit
Dependencies
PythonrequiredRuntime environment
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources