FenTechSolutions / CausalDiscoveryToolbox

Package for causal inference in graphs and in the pairwise settings. Tools for graph structure recovery and dependencies are included.
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html
MIT License
1.12k stars 197 forks source link

Error when trying to get the SID score of a predicted graph #119

Open OJ4227 opened 2 years ago

OJ4227 commented 2 years ago

I am working on windows, python version (3.9.1), cdt (0.5.23), pytorch (1.10.0).

I'm trying to predict the DAG of some discrete synthetic data. When I try to get the SID between a predicted graph and the ground truth using SID = cdt.metrics.SID(ground_truth, output), it throws up the error:

Traceback (most recent call last): File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\discovery6.py", line 139, in <module> SID = cdt.metrics.SID(ground_truth, output) File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\venv\lib\site-packages\cdt\metrics.py", line 273, in SID raise ImportError("SID R package is not available. Please check your installation.") ImportError: SID R package is not available. Please check your installation.

This looks like I haven't got SID installed, but when I run print(cdt.utils.R.RPackages) print(cdt.RPackages.check_R_package('SID'))

I get : ['init: False', 'pcalg: True', 'kpcalg: True', 'bnlearn: True', 'sparsebn: True', 'D2C: False', 'SID: True', 'CAM: False', 'RCIT: True'] True showing SID should be installed and accessible. What's stranger is that when I include the two print statements in the same script, above the line where I call SID, I get a different error:

R Python Error Output

C:\Users\order\AppData\Local\Temp\cdt_SID_89751cd4-4522-437b-a1bd-e449092d8fac\result.csv not found. Error in library(SID) : there is no package called 'SID' Execution halted Traceback (most recent call last): File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\discovery6.py", line 139, in <module> SID = cdt.metrics.SID(ground_truth, output) File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\venv\lib\site-packages\cdt\metrics.py", line 296, in SID raise e File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\venv\lib\site-packages\cdt\metrics.py", line 288, in SID sid_score = launch_R_script(Path("{}/utils/R_templates/sid.R".format(os.path.dirname(os.path.realpath(__file__)))), File "C:\Users\order\Documents\Oxford\4th Year\4YP\Pyro practice\venv\lib\site-packages\cdt\utils\R.py", line 224, in launch_R_script raise RuntimeError("RProcessError ") from None RuntimeError: RProcessError

Any help would be greatly appreciated!

OJ4227 commented 2 years ago

There isn't an issue when using a docker container so I'm assuming the problem is windows specific