BNM is a Python package for evaluating, comparing, and visualizing DAGs. It provides an intuitive interface for exploring both global and local graph structures, offering a rich set of metrics and visual tools.
Originally developed as DAGMetrics in R for analyzing Bayesian Networks in microbial abundance data (Averin et al., 2025), BNM is the Python implementation of DAGMetrics with extended functionality.
- Descriptive Metrics: Analyze structural properties of individual DAGs — including number of edges, colliders, root/leaf nodes, and more.
- Comparative Metrics: Quantify similarity between DAGs using metrics like Structural Hamming Distance (SHD), Hamming Distance (HD), true/false positives, F1 score, and others.
- Local Structure Analysis: Explore and compare the Markov blankets of selected nodes to understand the structure of a system at a granular level.
- Visual Comparisons: Generate side-by-side visualizations of DAGs, highlighting shared edges.
- Model Evaluation: Compare multiple models (e.g., from different algorithm runs or hyperparameter settings) to assess model stability and complexity.
You can install the package directly from GitHub:
pip install git+https://github.com/averinpa/bnm.git- User Guide and API Reference
- R Version of DAGMetrics
- Evaluating Directed Acyclic Graphs with DAGMetrics: Insights from Tuber and Soil Microbiome Data (Averin et al., 2025)
This project is licensed under the MIT License.
Pavel Averin
GitHub: @averinpa