dowhy
dowhy copied to clipboard
Support for Azua causal discovery models
[WIP] This is a work-in-progress PR for integrating causal discovery algorithms from Project Azua.
The intended use is:
graph = dowhy.learngraph(data,
method_name="azua.models.vicause.VICause", other_params_for_azua)
model = CausalModel(df, "treatment", "y", graph)
or using the object-oriented way,
model = CausalModel(data, "treatment", "y")
model.learn_graph(method_name="azua.models.vicause.VICause")
The relevant class from azua is called at runtime. The method needs to implement a fit function that accepts a pandas dataframe and returns a networkx DiGraph() object.
How does this sound?
Is it possible for the fit function to also accept a prior on the causal graph?
From: Amit Sharma @.> Sent: Thursday, November 11, 2021 6:30 AM To: microsoft/dowhy @.> Cc: Subscribed @.***> Subject: [microsoft/dowhy] Support for Azua causal discovery models (PR #333)
[WIP] This is a work-in-progress PR for integrating causal discovery algorithms from Project Azua.
The intended use is:
graph = dowhy.learngraph(data,
method_name="azua.models.vicause.VICause")
model = CausalModel(df, "treatment", "y", graph)
or using the object-oriented way,
model = CausalModel(data, "treatment", "y")
model.learn_graph(method_name="azua.models.vicause.VICause")
The relevant class from azua is called at runtime. The method needs to implement a fit function that accepts a pandas dataframe and returns a networkx DiGraph() object.
How does this sound?
You can view, comment on, or merge this pull request online at:
Commit Summary
File Changes
- M dowhy/causal_graph.pyhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333%2Ffiles%23diff-5037afb015107508279f956139d161d444c184d3374c026e03c8bd9b51c62919&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299836996%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Ft%2F5jA8A2KZYpN4i8Nx694Y0t2Njoa17biQx0DcsHJA%3D&reserved=0 (13)
- M dowhy/graph_learner.pyhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333%2Ffiles%23diff-e9af7e3c1436668b7a871111edf779ea481cec4e66a7e351d2ea464c9f238eaa&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299846978%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=7u76HS9zxYKtWvZUvdWs1UOY4c5lq8r00b%2Bar2VCQKM%3D&reserved=0 (4)
- M dowhy/graph_learners/cdt.pyhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333%2Ffiles%23diff-25e7719dce1df23f95d5323342cf3e511ed09d91c840262e794acdfef296c2b7&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299846978%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=FjNOeglaXNuOC%2BzVAoJKDLrmx7qkvP4Ps8lX4ui1CjE%3D&reserved=0 (10)
Patch Links:
- https://github.com/microsoft/dowhy/pull/333.patchhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333.patch&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299856973%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wgaot8kcV22500YEPkUzptrAemmT%2FKJAp7pZ4ZVVRWc%3D&reserved=0
- https://github.com/microsoft/dowhy/pull/333.diffhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333.diff&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299866977%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=mdxKLjZ%2BoMQWayak8LtsMFYL0B9jCHS%2BNXHtU7re%2B0Y%3D&reserved=0
You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299866977%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NT8PL6T8WSMJgVRpwn8Tnvlq%2BPdTJOPQWeskqcyeI7U%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABNUPUHXUJNMSECWOSG3NULULPHQFANCNFSM5H2TCXYA&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299876961%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rjxoZiMe%2FjCfFfRSxcvjm9h8MjokC9eKGCjoNgOy89Y%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299876961%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=7DHERX7uP3GqabgmM%2F8NXkFFmsPZissMO3%2Bc5CIyHTg%3D&reserved=0 or Androidhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299886974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kJ%2Bclsyp4tJ4Iqx7IMJzpQ%2FekLojKKgW3jg1Nzrorik%3D&reserved=0.
That's a good idea. And I believe some methods in Azua support it. We can add an optional parameter graph_prior as,
graph = dowhy.learngraph(data, graph_prior=user_graph,
method_name="azua.models.vicause.VICause", other_params_for_azua)
where user_graph is a networkx object provided by the user. This can be a partial graph with only some known edges. We would also want a way for a user to specify edges that should not exist and differentiate it from lack of knowledge about the edge. One option is to use networkx attributes. The user provides an edge but also provides an attribute that effect is zero on the edge.
When the user does not have a prior, the call remains the same.
graph = dowhy.learngraph(data,
method_name="azua.models.vicause.VICause", other_params_for_azua)
Some algorithms may treat the prior as a constraint, others may treat it as a prior that may be overridden by data. Do we want to expose that difference in the API contract as well?
From: Amit Sharma @.> Sent: Thursday, November 11, 2021 9:35 PM To: microsoft/dowhy @.> Cc: Emre Kiciman @.>; Comment @.> Subject: Re: [microsoft/dowhy] Support for Azua causal discovery models (PR #333)
That's a good idea. And I believe some methods in Azua support it. We can add an optional parameter graph_prior as,
graph = dowhy.learngraph(data, graph_prior=user_graph,
method_name="azua.models.vicause.VICause", other_params_for_azua)
where user_graph is a networkx object provided by the user. This can be a partial graph with only some known edges. We would also want a way for a user to specify edges that should not exist and differentiate it from lack of knowledge about the edge. One option is to use networkx attributes. The user provides an edge but also provides an attribute that effect is zero on the edge. When the user does not have a prior, the call remains the same.
graph = dowhy.learngraph(data,
method_name="azua.models.vicause.VICause", other_params_for_azua)
You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333%23issuecomment-966833562&data=04%7C01%7Cemrek%40microsoft.com%7Cfc700ce2d8674b0a617f08d9a59e25c2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722920938645932%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FlWiD4NrDIpcr2vvLVO%2FDdFoA4HjPCEcxUZZaCXgkF4%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABNUPUAG6G2DGUCTLSVDAVDULSRPVANCNFSM5H2TCXYA&data=04%7C01%7Cemrek%40microsoft.com%7Cfc700ce2d8674b0a617f08d9a59e25c2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722920938645932%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jPqkudCCwsnhtZXIWrKMKjOsg6JNbYQ2PT0tUsGG86U%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cemrek%40microsoft.com%7Cfc700ce2d8674b0a617f08d9a59e25c2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722920938655927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QuROGKdsMZG3EInyFORcn3%2FynC2pKYptJ%2BpnnkgMFdA%3D&reserved=0 or Androidhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cemrek%40microsoft.com%7Cfc700ce2d8674b0a617f08d9a59e25c2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722920938665922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yrtCAnBDQXziSPjHKBJRddey2MOZsozhH8rR%2Ff0EJ88%3D&reserved=0.
This looks like a great start.
- Is
azua.models.vicause.VICausevisible inside of DoWhy so we could actually test one of these paths? - What is
CausalModel? This seems a bit confusing asVICauseis also a causal model. - For priors, this is not currently implemented in FCause, but it's being worked on, and it would be good to incorporate it within the API. Here are my current thoughts https://www.overleaf.com/7647229536wjkvjxnhhfxy . The first iteration would focus on the "known edges" section, allowing users to specify one of the 6 prior constraints on the edge. This is more of a hard prior, but we could also fairly easily imagine soft prior versions of these 6 prior constraint options.
VICause is not visible, but you can provide the string "azua.models.vicause.VICause" and dowhy will automatically instantiate it. I just added the azua file that has details on the integration .
""" graph = dowhy.learngraph(data, graph_prior=user_graph, method_name="azua.models.vicause.VICause", other_params_for_azua) """
- CausalModel is the main class of DoWhy. It includes the causal graph, edge functions and any other attributes needed for causal analysis. You are right that VICause is also a causalmodel. In the SCM recipe for the API, we can use VICause to fit a CausalModel.
- Sounds good on priors.
Hey @amit-sharma @emrekiciman @ae-foster is the below method avaibale in DoWhy library ? seems like a good function
graph = dowhy.learngraph(data, method_name="azua.models.vicause.VICause", other_params_for_azua) model = CausalModel(df, "treatment", "y", graph)
I believe this PR is superseded by the recent work on do-discover. Is that correct @amit-sharma?
This PR is stale because it has been open for 60 days with no activity.
This PR was closed because it has been inactive for 7 days since being marked as stale.