Skip to content

Commit

Permalink
Remove some dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Bloebaum <[email protected]>
  • Loading branch information
bloebp committed Oct 4, 2024
1 parent 69075be commit b4ccd46
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 131 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ jobs:
version: "14.0"
directory: ${{ runner.temp }}/llvm

- name: Some cleanup for more disk space
run: |
rm -rf /usr/share/dotnet
rm -rf "$AGENT_TOOLSDIRECTORY"
apt-get autoremove -y
apt-get clean
df -h
- name: Install Python Dependencies
run: poetry install -E plotting -E pydot -E pygraphviz -E econml --with docs
run: poetry install

- name: Install Python Dependencies 2
run: poetry install -E plotting -E pydot -E pygraphviz

- name: Install Python Dependencies 2
run: poetry install -E econml --with docs

- run: git config --global --add safe.directory /__w/dowhy/dowhy

Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ jobs:
version: "14.0"
directory: ${{ runner.temp }}/llvm

- name: Some cleanup for more disk space
run: |
rm -rf /usr/share/dotnet
rm -rf "$AGENT_TOOLSDIRECTORY"
apt-get autoremove -y
apt-get clean
df -h
- name: Install Python Dependencies
run: poetry install -E plotting -E pydot -E pygraphviz -E econml --with docs
run: poetry install

- name: Install Python Dependencies 2
run: poetry install -E plotting -E pydot -E pygraphviz

- name: Install Python Dependencies 2
run: poetry install -E econml --with docs

- run: git config --global --add safe.directory /__w/dowhy/dowhy

Expand Down
8 changes: 0 additions & 8 deletions docs/source/dowhy.graph_learners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ dowhy.graph\_learners package
Submodules
----------

dowhy.graph\_learners.cdt module
--------------------------------

.. automodule:: dowhy.graph_learners.cdt
:members:
:undoc-members:
:show-inheritance:

dowhy.graph\_learners.ges module
--------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ Learning the causal graph is only necessary in case we cannot construct the grap

In many cases, the true causal structure for a given dataset may not be known. We can utilize *graph discovery* algorithms to provide candidate causal graphs consistent with the dataset. Such graphs can then be inspected, edited and modified by a user to match their domain expertise or world knowledge. Note that these graphs should be not used directly because graph discovery from observational data is a provably impossible problem in the fully non-parametric setting. Given a dataset, there exist multiple graphs that would lead to the exact same joint distribution and thus are indistinguishable based on the dataset (such graphs constitute the *Markov equivalence class*). As a result, graph discovery algorithms make certain assumptions to learn a graph and do not guarantee the validity of a learned graph.

DoWhy does not implement graph discovery algorithms, but provides a simple way to input the learnt graph from a discovery algorithm. The only constraint is that DoWhy expects the algorithm to output a directed acyclic graph (DAG). In the future, we expect to support learning causal graphs directly through integration with the `causal-learn <https://github.com/py-why/causal-learn>`_ and `dodiscover <https://github.com/py-why/dodiscover>`_ packages in PyWhy.

Graph discovery using CDT
-------------------------
Given a dataset as a pandas DataFrame, the following snippet learns the graph using LiNGAM algorithm and loads it in DoWhy. The algorithm implementation is in the Causal Discovery Toolbox (CDT) package which needs to be installed separately.

>>> from cdt.causality.graph import LiNGAM
>>> causal_graph = LiNGAM().predict(dataset)

For a full example using CDT, you can refer to the :doc:`../../example_notebooks/dowhy_causal_discovery_example`.
DoWhy does not implement graph discovery algorithms, but provides a simple way to input the learnt graph from a discovery algorithm. The only constraint is that DoWhy expects a directed acyclic graph (DAG) in the form of a networkx graph. For packages that implement different causal discovery algorithms, see the `causal-learn <https://github.com/py-why/causal-learn>`_ and `dodiscover <https://github.com/py-why/dodiscover>`_ packages in PyWhy.

Graph discovery using dodiscover
--------------------------------
Expand Down
62 changes: 1 addition & 61 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ pytest-split = ">=0.8.0"
nbformat = ">=5.4.0"
jupyter = ">=1.0.0"
flaky = ">=3.7.0"
keras = ">=2.9.0"
xgboost = ">=2.0.2"
mypy = ">=1.7.1"
torch = [
Expand Down Expand Up @@ -140,7 +139,6 @@ pydata-sphinx-theme = ">=0.9.0"
ipykernel = ">=6.15.1"
sphinx-copybutton = "0.5.0"
seaborn = ">=0.12.1"
cdt =">=0.6.0"

#
# Versions defined for security reasons
Expand Down
33 changes: 1 addition & 32 deletions tests/causal_estimators/test_econml_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def test_metalearners(self):
assert pytest.approx(sl_cate_estimates_test_f[0], 0.01) != sl_cate_estimates_test_f[1]

def test_iv_estimators(self):
keras = pytest.importorskip("keras")
# Setup data
data = datasets.linear_dataset(
10,
Expand All @@ -168,37 +167,7 @@ def test_iv_estimators(self):
# Test DeepIV
dims_zx = len(model._instruments) + len(model._effect_modifiers)
dims_tx = len(model._treatment) + len(model._effect_modifiers)
treatment_model = keras.Sequential(
[
keras.layers.Dense(128, activation="relu", input_shape=(dims_zx,)), # sum of dims of Z and X
keras.layers.Dropout(0.17),
keras.layers.Dense(64, activation="relu"),
keras.layers.Dropout(0.17),
keras.layers.Dense(32, activation="relu"),
keras.layers.Dropout(0.17),
]
)
response_model = keras.Sequential(
[
keras.layers.Dense(128, activation="relu", input_shape=(dims_tx,)), # sum of dims of T and X
keras.layers.Dropout(0.17),
keras.layers.Dense(64, activation="relu"),
keras.layers.Dropout(0.17),
keras.layers.Dense(32, activation="relu"),
keras.layers.Dropout(0.17),
keras.layers.Dense(1),
]
)
dmliv_estimate = model.estimate_effect(
identified_estimand,
method_name="iv.econml.iv.dml.DMLIV",
target_units=lambda df: df["X0"] > -1,
confidence_intervals=False,
method_params={
"init_params": {"discrete_treatment": False, "discrete_instrument": False},
"fit_params": {},
},
)

# Test IntentToTreatDRIV
data = datasets.linear_dataset(
10,
Expand Down

0 comments on commit b4ccd46

Please sign in to comment.