bd2kccd / causal-cmd

16 stars 8 forks source link

Output a DAG #101

Closed Gerlise closed 8 months ago

Gerlise commented 8 months ago

Hello,

I've been exploring various algorithms, including PC, but I've encountered a challenge: it doesn't seem to produce a DAG as I require. While there are command options like --outputCpdag and --cpdag that offer to output a DAG, unfortunately, they don't seem compatible with PC.

kvb2univpitt commented 8 months ago

Hi. Are able to convert your output to a DAG using tetrad?

jdramsey commented 8 months ago

Well, if it were a legit CPDAG, you could, though PC is often in the habit of not outputting a legit CPDAG. How about another option? There are three search algorithms in Tetrad that are always guaranteed to output a legit CPDAG:

FGES GRaSP BOSS

In fact, the latter two actually search for a DAG underneath and then convert this to a CPDAG (as you only actually know the CPDAG; you don't know the additional orientations. One thing I look to see, though is whether there's a way to get the DAG out of those methods before converting to CPDAG. Alternatively, you could select a DAG from a CPDAG in Tetrad. You could do this in Python using the py-tetrad package, https://github.com/cmu-phil/py-tetrad; I could tell you how, though first tell me if you're interested in that and then I'll type out how to do it.

Gerlise commented 8 months ago

With py-tetrad I would use the function dagFromCPDAG from GraphTransforms to get the DAG. However instead of using py-tetrad, I would like to use the command line to achieve this. So I tried to clone this repository and make minor changes to include this function but I'm not familiar with how to get this repository to a .jar file and if this is even possible.

jdramsey commented 8 months ago

Well if you can do that much, then I think we need to ask @kvb2univpitt how to do what you ask. Sounds like you're almost there!

Gerlise commented 8 months ago

Thank you for your help and I'll wait for his reply :)

kvb2univpitt commented 8 months ago

@Gerlise To compile the code, you will need the following:

Here's the instruction for installing Apache Maven.

Once you have Java and Maven installed, open up a terminal to where the POM.xml is and type the following command:

mvn clean package

The above command will build the executable jar for you. The executable jar causal-cmd-1.11.1-jar-with-dependencies.jar is located in the folder named target , created by Maven.

Hope that helps.

Gerlise commented 8 months ago

Thank you so much, I will try this out.