-
Notifications
You must be signed in to change notification settings - Fork 8
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
[ENH] Add the ability to convert an MAG to a PAG. #87
Conversation
Signed-off-by: Aryan Roy <[email protected]>
@adam2392 I will look for the exact algorithm and add it to the PR description. |
@adam2392 I can't find an implementation in the tetrad code base. Do you know where might I find it? |
Sorry you're right. They have a The MAG to PAG algorithm is just turning a normal DAG to a PAG (since a MAG Is a DAG, but with some extra restrictions). The DAG to PAG algorithm would leverage the orientation rules of the FCI algorithm, so Idk if it's worth adding here since we implemented that in dodiscover. FYI it is |
Codecov Report
@@ Coverage Diff @@
## main #87 +/- ##
==========================================
- Coverage 77.01% 76.99% -0.02%
==========================================
Files 42 42
Lines 3358 3360 +2
Branches 965 965
==========================================
+ Hits 2586 2587 +1
- Misses 570 571 +1
Partials 202 202
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@adam2392 for converting an MAG to PAG, do you want me to implement the FCI rules here? Or can we use the DagToPag class from dodiscover? |
Hmm good question. So the issue is that some of the rules rely on knowledge of the separating set, which basically requires re-running FCI with the graph as an oracle for the Conditional independence (CI) test. For now, you can just import dodiscover and run FCI. However, this might result in a bit of an annoyance as dodiscover API is relatively unstable. I am disinclined to add this to the pywhy-graphs codebase as a result. Sorry for bouncing you around, but perhaps we can revisit the PAG_to_MAG algorithm? #67 (comment) To perform the check on a PAG, it seems you have:
The MAG to a PAG is technically implemented in dodiscover via FCI with the graph as an oracle. I will need to think about how to best add this in. I would now focus on the PAG to MAG case. To setup the unit-tests, we can use dodiscover to convert DAGs to PAGs. |
Basically tldr: @aryan26roy let's start a new PR on doing PAG to MAG. In the unit-tests you can use dodiscover for now if you need to construct a valid PAG from a DAG. Alternatively, you can use Tetrad GUI to come up with some random PAGs. |
Should I go ahead with this @adam2392 ? |
This meaning adding FCI rules to the codebase? |
No, I meant importing dodiscover in pywhy-graphs. I was assuming that the API would have stabilised by now. |
It is not yet, so you can just add the FCI rules temporarily here to help convert a MAG to a PAG |
@adam2392 iirc, the FCI algorithm only converts a DAG to a PAG. Won't I need to convert the MAG to a DAG first? |
nope. I would remind yourself what the difference in skeleton structure between a DAG and a MAG ;) |
It's just that an MAG has more kinds of edges, right? |
What invariances does an equivalence class like a MAG encode? Do those invariances mean anything probabilistically and graphically? How does the skeleton of the PAG compare to the MAG and DAG? Finally, does it matter for FCI what is fed in? I'll let you explore the rest as I think the answer will be enlightening! Feel free to ping me about this PR when it's ready to review. |
I resolved CI issues in #99 . Feel free to merge/rebase changes |
@adam2392 I will read up on this and then implement the algorithms. Thanks for the help! |
The FCI rules can prolly be copied over as a refactored version from dodiscover. But yes agreed that reading up on this will help you understand how to test the MAG -> PAG properly and later PRs |
Signed-off-by: Aryan Roy <[email protected]>
@adam2392 I noticed that the FCI implementation in Dodiscover is a seperate file and a class. Should I do the same in pywhy-graphs? |
Sure |
@adam2392 The FCI implementation in dodiscover uses a lot of utilities from the dodiscover library. It is also a sub-class of another class called BaseConstraintDiscovery. Should I implement all of these things in pywhy-graphs or simply import them from dodiscover? |
Hmm okay I see, then perhaps let's forego this. It's too much work to replicate the code here and not worth it since it's already in dodiscover. We need this I guess for #67 ? I think at that step, we can just use dodiscover code for now. |
@aryan26roy just checking in here. Just wanted to make sure this seems fine to you? |
@adam2392 sorry for the late reply, it was Diwali this weekend and I was travelling. Yes, this seems alright to me. Will use the dodiscover code for now. |
Closes #85
Changes proposed in this pull request:
Before submitting
section of the
CONTRIBUTING
docs.Writing docstrings section of the
CONTRIBUTING
docs.After submitting