dowhy icon indicating copy to clipboard operation
dowhy copied to clipboard

Support for Azua causal discovery models

Open amit-sharma opened this issue 3 years ago • 7 comments

[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?

amit-sharma avatar Nov 11 '21 14:11 amit-sharma

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:

https://github.com/microsoft/dowhy/pull/333https://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%7C637722378299816998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=P97BaLaINdI%2BYWyCX%2BaTwRV%2FGhpF5oVTHScFMxx4Jk4%3D&reserved=0

Commit Summary

File Changes

(3 fileshttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdowhy%2Fpull%2F333%2Ffiles&data=04%7C01%7Cemrek%40microsoft.com%7Ce4fc9bcc09464d077cad08d9a51fcdaa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637722378299836996%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Z92WX6N2gF8s3t6XW5qu%2BNvOAHS1w67hpA3cMCf5xlI%3D&reserved=0)

Patch Links:

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.

emrekiciman avatar Nov 11 '21 17:11 emrekiciman

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)

amit-sharma avatar Nov 12 '21 05:11 amit-sharma

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.

emrekiciman avatar Nov 12 '21 08:11 emrekiciman

This looks like a great start.

  1. Is azua.models.vicause.VICause visible inside of DoWhy so we could actually test one of these paths?
  2. What is CausalModel? This seems a bit confusing as VICause is also a causal model.
  3. 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.

ae-foster avatar Nov 12 '21 13:11 ae-foster

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) """

  1. 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.
  2. Sounds good on priors.

amit-sharma avatar Nov 24 '21 16:11 amit-sharma

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)

saichaitanyamolabanti avatar May 21 '22 14:05 saichaitanyamolabanti

I believe this PR is superseded by the recent work on do-discover. Is that correct @amit-sharma?

emrekiciman avatar Sep 28 '22 08:09 emrekiciman

This PR is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Nov 28 '22 02:11 github-actions[bot]

This PR was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Dec 13 '22 02:12 github-actions[bot]