Diviyan-Kalainathan / SAMv1

Code of the first version of the SAM algorithm, available at https://arxiv.org/abs/1803.04929v1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

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

About

Code of the first version of the SAM algorithm, available at https://arxiv.org/abs/1803.04929v1

License:Apache License 2.0


Languages

Language:Python 100.0%