Skip to content

PGM-Lab/2025-IJAR-DCCC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Divide and Conquer Approach for Causal Computation

This bundle contains the manuscript published at International Journal of Approximate Reasoning and entitled "A Divide and Conquer Approach for Causal Computation". The organisation is the following:

  • examples: a toy example for running the method proposed in the paper.
  • ctfzeros: python sources implementing the method.
  • models: set of structural causal models in UAI format considered in the experimentation.
  • requirements.txt: code dependencies.

Setup

First of all, check the Python version. This sources have been coded with the following Python version:

!python --version
Python 3.11.2

Then, install the dependencies in the requirement.txt file. The main dependency is the python packege bcause (https://github.com/PGM-Lab/bcause).

!pip install --upgrade pip setuptools wheel
!pip install -r ./requirements.txt

Model and data

In this repository, we provide functionality for preprocessing the model and data so they could work we our inference algorithm:

from ctfzeros.prepro import load_and_preprocess
filepath = "./models/synthetic/simple_nparents2_nzr10_zdr05_13.uai"
datapath = "./models/synthetic/simple_nparents2_nzr10_zdr05_13.csv"

model, data, _, _ = load_and_preprocess(filepath, datapath)
model
<StructuralCausalModel (Y:2,X2:2,X1:2|Uy:16,Ux1:2,Ux2:2), dag=[Uy][Y|Uy:X2:X1][X2|Ux2][X1|Ux1][Ux1][Ux2]>
model.draw()

png

data
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
X2 X1 Y
0 0 1 0
1 1 1 0
2 0 1 1
3 0 1 1
4 0 1 1
... ... ... ...
995 0 1 1
996 0 1 0
997 0 1 1
998 0 1 0
999 0 1 1

1000 rows × 3 columns

Counterfactual inference

First, load corresponding modules for using DCCC and EMCC:

from ctfzeros.divideconquer import DCCC_inverted_tree
from bcause.inference.causal.multi import EMCC

Set up the DCCC inference engine with a number of solutions $N=20$. Then calculate the probability of sufficiency $PS(X_2,Y)$:

infDCCC = DCCC_inverted_tree(model, data, num_runs=20)
infDCCC.prob_sufficiency("X1", "Y")
[0.22996883482457, 0.6933748869005733]

Alternatively, each individual query can be obtained as follows:

Similarly, with the state of the art method EMCC interating up to 100 iterations each EM run.

infEMCC = EMCC(model,data,num_runs=20, max_iter=100)
infEMCC.prob_sufficiency("X1","Y")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages