Installation

bayesgm can be installed via pip, conda, and GitHub for Python users.

bayesgm includes both BGM and CausalBGM model families in one package. Model training can be faster with GPU, but it is not required.

Prerequisites

  1. Install conda via miniconda or anaconda.

  2. Create a new conda environment:

    conda create -n bayesgm-env python=3.9
    
  3. Activate your environment:

    conda activate bayesgm-env
    

Install with pip

Install from PyPI:

pip install bayesgm

If you get a Permission denied error, use:

pip install bayesgm --user

Install directly from GitHub source:

pip install git+https://github.com/liuq-lab/bayesgm.git

or install in editable mode:

git clone https://github.com/liuq-lab/bayesgm.git
cd bayesgm/src
pip install -e .

-e is short for --editable, which links the package to your local clone.

Install with conda

  1. Add conda-forge as highest-priority channel:

    conda config --add channels conda-forge
    
  2. Enable strict channel priority:

    conda config --set channel_priority strict
    
  3. Install:

    conda install -c conda-forge bayesgm
    

Verify installation

python -c "import bayesgm; print(bayesgm.__version__)"

Install R package for bayesgm

bayesgm R package is built with reticulate.

Install from GitHub:

install.packages("remotes")
remotes::install_github("liuq-lab/bayesgm", subdir = "r-package/bayesgm")

Or install from a downloaded local repository:

R CMD INSTALL path/to/bayesgm/r-package/bayesgm

Note: installing the R package does not automatically install the Python bayesgm package.

After installing the R package, you still need to make the Python bayesgm backend available to reticulate, for example by configuring:

library(bayesgm)

configure_bayesgm(
  python = "/path/to/python",
  pythonpath = "/path/to/bayesgm/src"
)