Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with isolates in do-calculus #100

Closed
sa-and opened this issue Mar 3, 2021 · 2 comments
Closed

Issues with isolates in do-calculus #100

sa-and opened this issue Mar 3, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@sa-and
Copy link

sa-and commented Mar 3, 2021

Hello,

In some cases when querying on a network on which a do-intervention has been done, an endless-loop in the build_join_tree() function of bbn.py occurs. This seems to happen when the preceding intervention disconnects the graph. Below you can see an example graph on which the problem occurred:

An intervention on x0 should remove the edge from x1 to x0. When querying for x1, the program runs in an endless-loop. More specifically (with bn having the structure as in the image and already fit to data).

ie = InferenceEngine(bn)
ie.do_intervention('x0', 1)
prediction = ie.query()['x1']  # this never terminates without raising any error

Interestingly, doing the intervention ie.do_intervention('x2', 1) on the above graph raises ValueError: Do calculus cannot be applied because it would result in an isolate. While this is already easier to debug, to the best of my knowledge this should also be a valid operation in the setting of causal graphs and do-calculus.

Environment:

python 3.8.5
# Name                    Version                   Build  Channel
backcall                  0.2.0              pyhd3eb1b0_0
ca-certificates           2021.1.19            haa95532_0
causalnex                 0.9.1                    pypi_0    pypi
certifi                   2020.12.5        py38haa95532_0
cloudpickle               1.6.0                    pypi_0    pypi
colorama                  0.4.4              pyhd3eb1b0_0
cycler                    0.10.0                   pypi_0    pypi
decorator                 4.4.2              pyhd3eb1b0_0
future                    0.18.2                   pypi_0    pypi
gym                       0.18.0                   pypi_0    pypi
ipython                   7.20.0           py38hd4e2768_1
ipython_genutils          0.2.0              pyhd3eb1b0_1
jedi                      0.17.0                   py38_0
joblib                    1.0.1                    pypi_0    pypi
kiwisolver                1.3.1                    pypi_0    pypi
matplotlib                3.3.4                    pypi_0    pypi
mypy                      0.812              pyhd3eb1b0_0
mypy_extensions           0.4.3                    py38_0
networkx                  2.5                      pypi_0    pypi
numpy                     1.20.1                   pypi_0    pypi
openssl                   1.1.1j               h2bbff1b_0
pandas                    1.2.2                    pypi_0    pypi
parso                     0.8.1              pyhd3eb1b0_0
patsy                     0.5.1                    pypi_0    pypi
pgmpy                     0.1.13                   pypi_0    pypi
pickleshare               0.7.5           pyhd3eb1b0_1003
pillow                    7.2.0                    pypi_0    pypi
pip                       21.0.1           py38haa95532_0
prettytable               0.7.2                    pypi_0    pypi
prompt-toolkit            3.0.8                      py_0
psutil                    5.8.0            py38h2bbff1b_1
pyglet                    1.5.0                    pypi_0    pypi
pygments                  2.8.0              pyhd3eb1b0_0
pyparsing                 2.4.7                    pypi_0    pypi
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1                    pypi_0    pypi
pytz                      2021.1                   pypi_0    pypi
scikit-learn              0.22.2                   pypi_0    pypi
scipy                     1.5.4                    pypi_0    pypi
setuptools                52.0.0           py38haa95532_0
six                       1.15.0                   pypi_0    pypi
sqlite                    3.33.0               h2a8f88b_0
stable-baselines3         0.10.0                   pypi_0    pypi
statsmodels               0.12.2                   pypi_0    pypi
torch                     1.7.1                    pypi_0    pypi
tqdm                      4.57.0                   pypi_0    pypi
traitlets                 5.0.5              pyhd3eb1b0_0
typed-ast                 1.4.2            py38h2bbff1b_1
typing_extensions         3.7.4.3            pyha847dfd_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wcwidth                   0.2.5                      py_0
wheel                     0.36.2             pyhd3eb1b0_0
wincertstore              0.2                      py38_0
wrapt                     1.11.2                   pypi_0    pypi
zlib                      1.2.11               h62dcd97_4
@ukm5
Copy link

ukm5 commented Jun 24, 2021

Thanks for posting this. I think you have summarized what I wanted to.
In fact, I have been facing a similar issue when I try to do a double intervention where I do not get an error saying there is an isolate but an infinite computational query is generated.

@oentaryorj oentaryorj added the bug Something isn't working label Jul 26, 2021
@FrancescaSogaroQB
Copy link
Contributor

FrancescaSogaroQB commented Aug 13, 2021

Thank you @ukm5 for reporting this. This is also linked to issue #45. The above has been fixed with this commit, and will be available in the next CausalNex release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants