SkillAgentSearch skills...

Bnlearn

Python package for Causal Discovery by learning the graphical structure of Bayesian networks. Structure Learning, Parameter Learning, Inferences, Sampling methods.

Install / Use

/learn @erdogant/Bnlearn

README

Python PyPI Version GitHub Repo stars License Forks Open Issues Project Status Downloads Downloads DOI Docs Medium GitHub repo size Donate Colab

<div>

<a href="https://erdogant.github.io/bnlearn/"><img src="https://github.com/erdogant/bnlearn/blob/master/docs/figs/logo.png" width="175" align="left" /></a> bnlearn is Python package for causal discovery by learning the graphical structure of Bayesian networks, parameter learning, inference, and sampling methods. Because probabilistic graphical models can be difficult to use, Bnlearn contains the most-wanted pipelines. Navigate to API documentations for more detailed information. ⭐️ Star it if you like it ⭐️

</div>

Key Features

| Feature | Description | Medium | Gumroad/Podcast | |--------|-------------|---|---| | Causal Discovery - Overview and Starters Guide | Learn the basics of causal modelling. |link|---| | Structure Learning | Learn the model structure from data or with expert knowledge. |link|---| | Causal Predictions | Learn to make causal predictions. |link|---| | Parameter Learning | Estimate model parameters (e.g., conditional probability distributions) from observed data. |link|---| | Causal Inference | Compute interventional and counterfactual distributions using do-calculus. |link|---| | Generate Synthetic Data | Generate synthetic data. |link|---| | Discretize Data | Discretize continuous datasets. |---|---| | Comparisons | Comparison with other causal libraries. |link|---|


Resources and Links


The following functions are available after installation:

| Feature | Description | |--------|-------------| | Key Pipelines | | | Structure learning | bn.structure_learning.fit() | | Parameter learning | bn.parameter_learning.fit() | | Inference | bn.inference.fit() | | Make predictions | bn.predict() | | Generate Synthetic Data | bn.sampling() | | Compute Edge Strength | bn.independence_test() | | Key Functions | | | Imputations | bn.knn_imputer() | | Discretizing | bn.discretize() | | Check Model Parameters | bn.check_model() | | Create DAG | bn.make_DAG() | | Get Node Properties | bn.get_node_properties() | | Get Edge Properties | bn.get_edge_properties() | | Get Parents From Edges | bn.get_parents() | | Generate Default CPT per Node | bn.generate_cpt() | | Generate Default CPTs for All Edges | bn.build_cpts_from_structure() | | Make Plots | | | Plotting | bn.plot() | | Plot Graphviz | bn.plot_graphviz() | | Compare 2 Networks | bn.compare_networks() | | Load DAG (bif files) | bn.import_DAG() | | Load Examples | bn.import_example() | | Transformation Functions | | | Convert DAG to Undirected | bn.to_undirected() | | Convert to one-hot | bn.df2onehot() | | Convert Adjacency Matrix to Vector | bn.adjmat2vec() | | Convert Adjacency Matrix to Dictionary | bn.adjmat2dict() | | Convert Vector to Adjacency Matrix | bn.vec2adjmat() | | Convert DAG to Adjacency Matrix | bn.dag2adjmat() | | Convert DataFrame to Onehot | bn.df2onehot() | | Convert Query to DataFrame | bn.query2df() | | Convert Vector to DataFrame | bn.vec2df() | | Metrics | | | Compute Topological Ordering | bn.topological_sort() | | Compute Structure Scores | bn.structure_scores() | | General | | | Save Model | bn.save() | | Load Model | bn.load() | | Print CPTs | bn.print_CPD() |


Installatio

View on GitHub
GitHub Stars617
CategoryEducation
Updated1d ago
Forks56

Languages

Jupyter Notebook

Security Score

85/100

Audited on Mar 24, 2026

No findings