Code for the Structural Agnostic Model (https://arxiv.org/abs/1803.04929)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
datasets @ 25b8b5e
sam
test
.gitignore
.gitmodules
LICENSE.md
README.md
requirements.txt
setup.py

README.md

SAM: Structural Agnostic Model, Causal Discovery and Penalized Adversarial Learning.

Code in PyTorch. Link to the paper: https://arxiv.org/abs/1803.04929

In order to use SAM:

  1. Install the package requirements with pip install -r requirements.txt. For PyTorch visit: http://pytorch.org
  2. Install the package with the command: python setup.py develop --user
  3. Execute the SAM by including the desired options:
import pandas as pd
from sam import SAM
sam = SAM()
data = pd.read_csv("test/G5_v1_numdata.tab", sep="\t")
output = sam.predict(data, nruns=12) # Recommended if high computational capability available, else nruns=1

We highly recommand to use GPUs if possible. Here is an example for 2 GPUs:

import pandas as pd
from sam import SAM
sam = SAM()
data = pd.read_csv("test/G5_v1_numdata.tab", sep="\t")
output = sam.predict(data, nruns=12, gpus=2, njobs=4) # As the model is small, we recommand using 2 jobs on each GPU

In order to download the datasets used in the paper as well as the generators, download the submodule "datasets" (458MB):

git submodule update --init

The acyclic graphs for the mechanisms Linear, GP Add, GP Mix, Sigmoid Add and Sigmoid Mix were generated using the software provided at : https://github.com/bquast/ANM/tree/master/codeANM