Skip to content

Commit d47af78

Browse files
authored
Release 0.3.5 (#72)
* Release 0.3.5 * Add devcontainer badge to README.md * Add missing dotfiles * Delete removed files * Add missing pre-commit config * Fix extra argument for pre-commit
1 parent 2ae92df commit d47af78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5700
-2313
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"target": "dev"
77
},
88
"runArgs": [
9-
// The default shared memory size of Docker is 64MB which can lead to memory
10-
// issues when using Pytorch dataloaders with multiple workers.
11-
// See https://github.com/aws/sagemaker-python-sdk/issues/937 and
12-
// https://github.com/pytorch/pytorch#docker-image.
9+
// give headspace for pytorch dataloaders passing tensors across processes
1310
"--shm-size=1gb"
1411
],
1512
"containerEnv": {
@@ -22,7 +19,8 @@
2219
"hostRequirements": {
2320
"gpu": "optional" // Mount GPU(s) if available
2421
},
25-
"postStartCommand": "git config --global core.editor \"code --wait\"",
22+
"postCreateCommand": "pre-commit install",
23+
"postStartCommand": "git config --global core.editor \"code --wait\" && poetry install",
2624
"shutdownAction": "none",
2725
"customizations": {
2826
"vscode": {
@@ -33,7 +31,7 @@
3331
"python.testing.pytestEnabled": true,
3432
"python.testing.pytestArgs": [
3533
"--continue-on-collection-errors",
36-
"causica/test"
34+
"test"
3735
],
3836
"python.testing.unittestEnabled": false,
3937
"vim.textwidth": 120,

.github/workflows/ci-build.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,41 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
with:
18-
path: "repo"
1917

2018
- uses: actions/setup-python@v2
2119
with:
22-
python-version: "3.9"
20+
python-version: "3.10"
2321

2422
- uses: actions/cache@v3
2523
with:
2624
path: ~/.cache/pypoetry/virtualenvs
27-
key: ${{ hashFiles('repo/poetry.lock') }}
25+
key: ${{ hashFiles('poetry.lock') }}
2826
id: cache
29-
27+
3028
- name: Install poetry
3129
run: |
3230
curl -sSL https://install.python-poetry.org | python3 -
3331
3432
- name: Install dependencies
35-
shell: bash -l {0}
3633
run: |
37-
cd repo
38-
poetry env use 3.9
34+
poetry env use 3.10
3935
poetry install
4036
if: steps.cache.outputs.cache-hit != 'true'
4137

38+
- name: Verify pre-commit checks
39+
uses: pre-commit/[email protected]
40+
with:
41+
extra_args: --all-files
42+
4243
- name: Test with pytest
43-
shell: bash -l {0}
44-
run: |
45-
cd repo
46-
poetry run python -m pytest ./test
44+
run: poetry run python -m pytest ./test
4745

4846
- name: Create build artifact
49-
shell: bash -l {0}
50-
run: |
51-
cd repo
52-
poetry build
47+
run: poetry build
5348

5449
- name: Upload build artifact
55-
# if: github.ref == 'refs/heads/main' # only create artifacts on push to main
5650
uses: actions/upload-artifact@v3
5751
with:
5852
name: Build artifacts
59-
path: ./repo/dist
60-
retention-days: 90
53+
path: ./dist
54+
retention-days: 90

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: black
5+
name: black
6+
entry: poetry run black
7+
language: system
8+
types_or: [python, jupyter]
9+
args: [--config=./pyproject.toml]
10+
- repo: local
11+
hooks:
12+
- id: isort
13+
name: isort
14+
entry: poetry run isort
15+
language: system
16+
types: [python]
17+
- repo: local
18+
hooks:
19+
- id: poetry lock
20+
name: poetry lock check
21+
entry: poetry lock --check
22+
pass_filenames: false
23+
language: system
24+
- repo: local
25+
hooks:
26+
- id: mypy
27+
name: mypy
28+
entry: poetry run mypy
29+
pass_filenames: false
30+
language: system
31+
types: [python]
32+
args: ["--config-file=pyproject.toml", "."]
33+
- repo: local
34+
hooks:
35+
- id: pylint
36+
name: pylint
37+
entry: poetry run pylint
38+
language: system
39+
types: [python]

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ RUN curl -sSL https://install.python-poetry.org | python3 -
3131
WORKDIR /workspaces/causica
3232
COPY pyproject.toml poetry.lock ./
3333
RUN --mount=type=cache,target=/root/.cache/pypoetry,sharing=locked \
34-
mkdir -p src/causica && touch README.md src/causica/__init__.py && \
35-
poetry install --only main
34+
poetry install --only main --no-root --no-directory
3635

3736
FROM base as deploy
3837
COPY . /workspaces/causica
@@ -74,4 +73,4 @@ RUN <<EOT
7473
EOT
7574

7675
RUN --mount=type=cache,target=/root/.cache/pypoetry,sharing=locked \
77-
poetry install --with dev
76+
poetry install --with dev --no-root --no-directory

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
[![Causica CI Build](https://github.com/microsoft/causica/actions/workflows/ci-build.yml/badge.svg)](https://github.com/microsoft/causica/actions/workflows/ci-build.yml)
2+
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/causica)
3+
24

35
# Causica
46

57
## Overview
6-
7-
Causal machine learning enables individuals and organizations to make better data-driven decisions. In particular, causal ML allows us to answer “what if” questions about the effect of potential actions on outcomes.
8-
8+
9+
Causal machine learning enables individuals and organizations to make better data-driven decisions. In particular, causal ML allows us to answer “what if” questions about the effect of potential actions on outcomes.
10+
911
Causal ML is a nascent area, we aim to enable a **scalable**, **flexible**, **real-world applicable end-to-end** causal inference framework. In perticular, we bridge between causal discovery, causal inference, and deep learning to achieve the goal. We aim to develop technology can automate causal decision-making using existing observational data alone, output both the discovered causal relationships and estimate the effect of actions simultaneously.
10-
12+
1113
Causica is a deep learning library for end-to-end causal inference, including both causal discovery and inference. It implements deep end-to-end inference framework [2] and different alternatives.
12-
14+
1315
This project splits the interventional decision making from observational decision making Azua repo found here [Azua](https://github.com/microsoft/project-azua).
1416

1517
This codebase has been heavily refactored, you can find the previous version of the code [here](https://github.com/microsoft/causica/releases/tag/v0.0.0).
@@ -26,7 +28,7 @@ pip install causica
2628

2729
## About
2830

29-
Real-world data-driven decision making requires causal inference to ensure the validity of drawn conclusions. However, it is very uncommon to have a-priori perfect knowledge of the causal relationships underlying relevant variables. DECI allows the end user to perform causal inference without having complete knowledge of the causal graph. This is done by combining the causal discovery and causal inference steps in a single model. DECI takes in observational data and outputs ATE and CATE estimates.
31+
Real-world data-driven decision making requires causal inference to ensure the validity of drawn conclusions. However, it is very uncommon to have a-priori perfect knowledge of the causal relationships underlying relevant variables. DECI allows the end user to perform causal inference without having complete knowledge of the causal graph. This is done by combining the causal discovery and causal inference steps in a single model. DECI takes in observational data and outputs ATE and CATE estimates.
3032

3133
For more information, please refer to the [paper](https://arxiv.org/abs/2202.02195).
3234

@@ -37,7 +39,7 @@ DECI is a generative model that employs an additive noise structural equation mo
3739

3840
**Simulation-based Causal Inference**
3941

40-
DECI estimates causal quantities (ATE) by applying the relevant interventions to its learnt causal graph (i.e. mutilating incoming edges to intervened variables) and then sampling from the generative model. This process involves first sampling a vector of exogenous noise from the learnt noise distribution and then forward simulating the SEM until an observation vector is obtained. ATE can be computed via estimating an expectation over the effect variable of interest using MonteCarlo samples of the intervened distribution of observations.
42+
DECI estimates causal quantities (ATE) by applying the relevant interventions to its learnt causal graph (i.e. mutilating incoming edges to intervened variables) and then sampling from the generative model. This process involves first sampling a vector of exogenous noise from the learnt noise distribution and then forward simulating the SEM until an observation vector is obtained. ATE can be computed via estimating an expectation over the effect variable of interest using MonteCarlo samples of the intervened distribution of observations.
4143

4244
## How to run
4345

@@ -60,7 +62,7 @@ The Spline model uses a flexible spline flow that is learnt from the data. This
6062

6163
To use DECI to learn the functional relationships, remove the variational distribution terms from the loss and replace the sample with the known graph.
6264

63-
## Further extensions
65+
## Further extensions
6466

6567
For now, we have removed Rhino and DDECI from the codebase but they will be added back. You can still access the previously released versions [here](https://github.com/microsoft/causica/releases/tag/v0.0.0).
6668

examples/csuite_example.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
" JointNoiseModule,\n",
3737
" create_noise_modules,\n",
3838
")\n",
39-
"from causica.functional_relationships import ICGNN\n",
39+
"from causica.functional_relationships import DECIEmbedFunctionalRelationships\n",
4040
"from causica.graph.dag_constraint import calculate_dagness\n",
4141
"from causica.sem.sem_distribution import SEMDistributionModule\n",
4242
"from causica.training.auglag import AugLagLossCalculator, AugLagLR, AugLagLRConfig"
@@ -168,12 +168,12 @@
168168
"metadata": {},
169169
"outputs": [],
170170
"source": [
171-
"icgnn = ICGNN(\n",
171+
"functional_relationships = DECIEmbedFunctionalRelationships(\n",
172172
" shapes=tensordict_shapes(dataset_train),\n",
173173
" embedding_size=32,\n",
174174
" out_dim_g=32,\n",
175-
" norm_layer=torch.nn.LayerNorm,\n",
176-
" res_connection=True,\n",
175+
" num_layers_g=2,\n",
176+
" num_layers_zeta=2,\n",
177177
")"
178178
]
179179
},
@@ -213,7 +213,7 @@
213213
"metadata": {},
214214
"outputs": [],
215215
"source": [
216-
"sem_module: SEMDistributionModule = SEMDistributionModule(adjacency_dist, icgnn, noise_module)\n",
216+
"sem_module: SEMDistributionModule = SEMDistributionModule(adjacency_dist, functional_relationships, noise_module)\n",
217217
"\n",
218218
"sem_module.to(device);"
219219
]
@@ -233,7 +233,7 @@
233233
"outputs": [],
234234
"source": [
235235
"modules = {\n",
236-
" \"icgnn\": sem_module.functional_relationships,\n",
236+
" \"functional_relationships\": sem_module.functional_relationships,\n",
237237
" \"vardist\": sem_module.adjacency_module,\n",
238238
" \"noise_dist\": sem_module.noise_module,\n",
239239
"}\n",

examples/multi_investment_sales_attribution.ipynb

Lines changed: 67 additions & 59 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)