https://github.com/cbg-ethz/sgs

Inference in Bayesian Networks with R

https://github.com/cbg-ethz/sgs

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.5%) to scientific vocabulary

Keywords

bayesian-network bayesian-networks graphical-models inference missing-data probabilistic-graphical-models
Last synced: 5 months ago · JSON representation

Repository

Inference in Bayesian Networks with R

Basic Info
Statistics
  • Stars: 11
  • Watchers: 4
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Topics
bayesian-network bayesian-networks graphical-models inference missing-data probabilistic-graphical-models
Created about 4 years ago · Last pushed about 3 years ago
Metadata Files
Readme Changelog License

ReadMe.md

Inference in Bayesian Networks

License: GPL v3

SGS is an R package for inference in Bayesian networks. It allows for efficient exact and approximate inference that works both in low- and high-dimensional settings. Efficient marginalization is reached by splitting the calculation into sub-calculations of lower dimensionality. This code is an implementation of the paper High-Dimensional Inference in Bayesian Networks, arXiv preprint.

Implemented exact inference methods: - SubGroupSeparation (fastest) - Junction-tree algorithm - Complete enumeration

Implemented approximate inference methods: - SubGroupSeparation (highest accuracy) - Loopy belief propagation - Markov chain Monte Carlo (MCMC) sampling

Installation

In order to install the package, it suffices to launch R CMD INSTALL path/to/SGS from a terminal, or make install from within the package source folder.

Being hosted on GitHub, it is possible to use the install_github tool from an R session:

``` if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install(c("graph", "Rgraphviz", "RBGL"))

library("devtools") install_github("cbg-ethz/SGS") ```

The packages "graph", "Rgraphviz" and "RBGL" need to be installed from BioConductor, as they are not hosted on CRAN.

SGS requires R >= 3.5, and depends on bitops and methods. Other packages are requested in order to plot graphs, but are not mandatory.

Examples

``` library(SGS)

create BN and label variables

set.seed(6) myBayesNet <- randomBN(3) myBayesNet@variables <- c("rain", "sprinkler", "wet grass") plot_bn(myBayesNet)

what's the probability of having rain and wet grass at the same time?

define observed variables and calculate marginal probability

myObserved <- list(observed.vars=c("rain", "wet grass"), observed.vals=c(2,2)) exactInference(myBayesNet,myObserved)

another example:

let's learn the Bayesian network from the "Asia dataset"

asiabn <- learnbn(Asia) plotbn(asiabn)

now we can do the inference on the learned Bayesian network

myObserved <- list(observed.vars=c("X", "D"), observed.vals=c(1,1)) exactInference(asia_bn, myObserved) ```

Benchmark Results

We benchmarked the performance of our SGS method against standard inference schemes (Gibbs sampling and loopy belief propagation) over a broad range of different Bayesian networks. The results are summarized in the Figure below (lower is better), displaying the normalized root mean squared error (NRMSE). To reproduce the results, run the scripts in the benchmark folder.

SGS

Reference

If you find this code useful, please consider citing:

Fritz M. Bayer, Giusi Moffa, Niko Beerenwinkel, Jack Kuipers. High-Dimensional Inference in Bayesian Networks, arXiv preprint, 2021

@article{bayer2021marginalization, title={High-Dimensional Inference in Bayesian Networks}, author={Bayer, Fritz M and Moffa, Giusi and Beerenwinkel, Niko and Kuipers, Jack}, journal={arXiv preprint arXiv:2112.09217}, year={2021} }

Owner

  • Name: Computational Biology Group (CBG)
  • Login: cbg-ethz
  • Kind: organization
  • Location: Basel, Switzerland

Beerenwinkel Lab at ETH Zurich

GitHub Events

Total
  • Watch event: 1
  • Fork event: 1
Last Year
  • Watch event: 1
  • Fork event: 1

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 115
  • Total Committers: 2
  • Avg Commits per committer: 57.5
  • Development Distribution Score (DDS): 0.026
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Fritz Bayer f****r@y****m 112
PhysFritz 3****z 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • fritzbayer (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • bitops * depends
  • methods * depends
  • Bestie * imports
  • BiDAG * imports
  • RColorBrewer * imports
  • cowplot * imports
  • ggplot2 * imports
  • ggpubr * imports
  • gridExtra * imports
  • igraph * imports
  • pcalg * imports
  • stats * imports
  • RBGL * suggests
  • Rgraphviz * suggests
  • graph * suggests
  • knitr * suggests
  • qgraph * suggests
  • rmarkdown * suggests
  • testthat * suggests
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action 4.1.4 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite