Skip to content
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

Equations to define causal graph including causal mechanism #1066

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b94a3ec
added initial graph to equation logic
bhatt-priyadutt Nov 7, 2023
9b1d042
corrected some logic and refactored, modularized
bhatt-priyadutt Nov 7, 2023
395d1fa
Fix frontdoor estimation bug (#1060)
amit-sharma Nov 10, 2023
eb88735
Add new method to estimate KL divergence using classifier
bloebp Oct 20, 2023
b9ae10b
Fix issue with auto assignment with imbalanced classes
bloebp Nov 9, 2023
57656af
Fix issue with linear regressor with fixed parameters
bloebp Nov 9, 2023
9d77022
Revise display of notebook examples in documentation
bloebp Nov 13, 2023
3f8bf25
fixed fit error
bhatt-priyadutt Nov 16, 2023
cf14caa
Remove 'experimental' disclaimer from GCM modules
bloebp Nov 10, 2023
e846851
Address issue with timeouts in unit change tests
bloebp Nov 15, 2023
4d83d89
fixed spacing error
bhatt-priyadutt Nov 16, 2023
1d3cd9a
Add new GCM model evaluation module
bloebp Oct 24, 2023
601c2ae
Remove deprecated feature.py module from GCM
bloebp Nov 10, 2023
b2e75a7
Fix issue in KL estimation using knn
bloebp Nov 17, 2023
18b0f9b
fixed some errors and reformatted and added some validation logic and…
bhatt-priyadutt Nov 18, 2023
ced5d72
Fix handling of NaN values in MedianCDFQuantileScorer
bloebp Nov 17, 2023
0b8f418
Add GCM online shop example notebook
bloebp Nov 14, 2023
5a6ce23
Bump actions/github-script from 6 to 7
dependabot[bot] Nov 20, 2023
cae656a
Fix issue with MedianCDFQuantileScorer
bloebp Nov 20, 2023
c88cc83
Fix issue in bar_plot with misspecified confidence intervals
bloebp Nov 20, 2023
bd23532
Change default parameter of SVC model in the GCM module
bloebp Oct 17, 2023
bd4f95f
Add new example notebook demonstrating the use of the ICC methond in GCM
bloebp Nov 14, 2023
7c015b7
Extend GCM model evaluation by additional metrics
bloebp Nov 21, 2023
132cf95
added sanitize and some other logics to cater to disconnected root no…
bhatt-priyadutt Nov 26, 2023
4fd0a92
auto identify the effect modifier columns for `effect' method for Eco…
amit-sharma Nov 27, 2023
2a8e49a
Proposal: Finalize functional API refactor - deprecate causal graph (…
bloebp Nov 27, 2023
ae9ccd9
added mode checks and validaion and removed compile func
bhatt-priyadutt Nov 27, 2023
af61e42
added handling for undefined nodes and node redudancy
bhatt-priyadutt Nov 28, 2023
c41cefc
Add explicit support for discrete ANMs
bloebp Nov 22, 2023
489c812
Overhauled readme
bloebp Nov 26, 2023
a2a79b3
added decision-making intro and econml code snippet
amit-sharma Nov 28, 2023
bddbb3a
Update
bloebp Nov 28, 2023
031d49e
Update
bloebp Nov 28, 2023
3475b19
Fix documentation box
bloebp Nov 28, 2023
591e9d9
Add pywhy refrence
bloebp Nov 29, 2023
f455c56
Make example sections more prominent
bloebp Nov 29, 2023
9ebf9e3
Revised documentation
bloebp Nov 26, 2023
918efc6
Change readme notebook links to compiled HTML versions
bloebp Dec 1, 2023
357c092
updated extract parent nodes logic
bhatt-priyadutt Dec 1, 2023
1d050f0
Bug fix: Linear regression CATE estimates were not shown even when ne…
amit-sharma Dec 3, 2023
048117c
Bug fix for frontdoor identification and a new set of tests (#1093)
amit-sharma Dec 3, 2023
2900fd7
Link list of estimators in estimate_method docstring (#1094)
amit-sharma Dec 3, 2023
299b1d7
Remove DeepIV econml estimator from notebook and fix flaky test (#1091)
amit-sharma Dec 3, 2023
1df8561
Fix issue in falsify method when no tests were performed
bloebp Nov 30, 2023
5ccc808
added unknown mech logic support and did some refactoring
bhatt-priyadutt Dec 3, 2023
da8141e
added more test cases
bhatt-priyadutt Dec 3, 2023
ebc8dca
added initial graph to equation logic
bhatt-priyadutt Nov 7, 2023
3375122
corrected some logic and refactored, modularized
bhatt-priyadutt Nov 7, 2023
9e63ed3
fixed fit error
bhatt-priyadutt Nov 16, 2023
8aa873d
fixed spacing error
bhatt-priyadutt Nov 16, 2023
7b543d7
fixed some errors and reformatted and added some validation logic and…
bhatt-priyadutt Nov 18, 2023
4edb3a4
added sanitize and some other logics to cater to disconnected root no…
bhatt-priyadutt Nov 26, 2023
01bc536
added mode checks and validaion and removed compile func
bhatt-priyadutt Nov 27, 2023
e38bdd5
added handling for undefined nodes and node redudancy
bhatt-priyadutt Nov 28, 2023
1458a05
updated extract parent nodes logic
bhatt-priyadutt Dec 1, 2023
516c14c
added unknown mech logic support and did some refactoring
bhatt-priyadutt Dec 3, 2023
4213703
added more test cases
bhatt-priyadutt Dec 3, 2023
dee6b9a
Merge remote-tracking branch 'origin/equations-to-define-causal-graph…
bhatt-priyadutt Dec 3, 2023
619d894
removed comment
bhatt-priyadutt Dec 4, 2023
7190e30
cmit
bhatt-priyadutt Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/advanced-on-demand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
if: ${{ github.event.comment.body == 'test advanced'}}
steps:
- name: Message Initiating
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
github.issues.createComment({
Expand All @@ -28,7 +28,7 @@ jobs:
});
- name: Get PR SHA
id: sha
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Message success
if: ${{ success() }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
github.issues.createComment({
Expand All @@ -80,7 +80,7 @@ jobs:
});
- name: Message failure
if: ${{ failure() }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
github.issues.createComment({
Expand Down
483 changes: 117 additions & 366 deletions README.rst

Large diffs are not rendered by default.

Binary file added docs/images/dowhy-features.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/401k-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/confounder-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/dowhy-econml-tutorial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/draw-samples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/gcm-falsify-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/icc-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/online-shop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/cite.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Citing this package
-------------------

If you find DoWhy useful for your work, please cite the following two references:
If you find DoWhy useful for your work, please cite **both** of the following two references:

- Amit Sharma, Emre Kiciman. DoWhy: An End-to-End Library for Causal Inference. 2020. https://arxiv.org/abs/2011.04216
- Patrick Blöbaum, Peter Götz, Kailash Budhathoki, Atalanti A. Mastakouri, Dominik Janzing. DoWhy-GCM: An extension of DoWhy for causal inference in graphical causal models. 2022. https://arxiv.org/abs/2206.06821
Expand Down
366 changes: 366 additions & 0 deletions docs/source/example_notebooks/2021 Data.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/source/example_notebooks/2022 First Day.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Date,Shopping Event?,Ad Spend,Page Views,Unit Price,Sold Units,Revenue,Operational Cost,Profit
2022-01-01,False,1392.3358280937282,10018,899.1,2756,2477919.6,1879401.202414113,598518.397585887
91 changes: 91 additions & 0 deletions docs/source/example_notebooks/2022 First Quarter.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Date,Shopping Event?,Ad Spend,Page Views,Unit Price,Sold Units,Revenue,Operational Cost,Profit
2022-01-01,False,1392.3358280937282,10018,899.1,2756,2477919.6,1879401.202414113,598518.397585887
2022-01-02,False,1391.3913808337466,10038,899.1,2726,2450946.6,1864399.9104804778,586546.6895195222
2022-01-03,False,1293.990843338987,9941,899.1,2656,2388009.6,1829299.397053411,558710.2029465891
2022-01-04,False,1212.5903975212161,9950,899.1,2741,2464433.1,1871716.1029819865,592716.9970180136
2022-01-05,False,1182.4698371589263,9764,899.1,2697,2424872.7,1849701.0618950732,575171.638104927
2022-01-06,False,1467.445551067856,10207,899.1,2738,2461735.8000000003,1870468.5168295426,591267.2831704577
2022-01-07,True,2141.808717727631,17412,831.3573114052718,5643,4691349.308259949,3323643.689932692,1367705.6183272572
2022-01-08,False,1234.829256168011,10071,899.1,2723,2448249.3000000003,1862749.2170296635,585500.0829703368
2022-01-09,False,1376.020055104923,10129,899.1,2688,2416780.8000000003,1845378.2985341656,571402.5014658347
2022-01-10,False,1340.02761092149,9984,899.1,2794,2512085.4,1898350.3293293247,613735.0706706753
2022-01-11,False,1273.287440057397,9863,899.1,2696,2423973.6,1849280.0494022565,574693.5505977436
2022-01-12,False,1141.693146346015,9916,899.1,2759,2480616.9,1880646.1331021162,599970.7668978837
2022-01-13,False,1155.81122050363,10173,899.1,2831,2545352.1,1916660.5228116934,628691.5771883067
2022-01-14,False,1378.6091490867877,10145,899.1,2825,2539957.5,1913893.7435477874,626063.7564522126
2022-01-15,False,1293.478645787744,10082,899.1,2770,2490507.0,1886306.3993566553,604200.6006433447
2022-01-16,False,1235.8202923804415,10099,899.1,2860,2571426.0,1931237.6707989252,640188.3292010748
2022-01-17,False,1249.9174124330566,9907,899.1,2717,2442854.7,1859750.6417620734,583104.0582379268
2022-01-18,False,1271.47439232518,9888,899.1,2677,2406890.7,1839773.284036592,567117.4159634081
2022-01-19,False,1373.2226475584066,9764,899.1,2696,2423973.6,1849376.4607885955,574597.1392114046
2022-01-20,False,1340.3791158099252,10054,899.1,2768,2488708.8000000003,1885345.0795596098,603363.7204403905
2022-01-21,False,1128.1931917991249,9924,899.1,2764,2485112.4,1883130.7364539118,601981.6635460882
2022-01-22,False,1162.9911436309628,9648,899.1,2627,2361935.7,1814674.633357068,547261.0666429321
2022-01-23,False,1128.2222747689384,9842,899.1,2545,2288209.5,1773630.7895691658,514578.7104308342
2022-01-24,False,1113.8360503017068,9802,899.1,2649,2381715.9,1825615.6047651214,556100.2952348785
2022-01-25,False,1410.401967178016,10229,899.1,2770,2490507.0,1886417.1431889622,604089.8568110378
2022-01-26,False,1440.3835630651943,9978,899.1,2791,2509388.1,1896940.9275888735,612447.1724111266
2022-01-27,True,2988.4214329976066,17915,831.9998636067619,6240,5191679.148906195,3622996.5890260655,1568682.559880129
2022-01-28,False,1487.5363138089551,9990,899.1,2741,2464433.1,1871993.5629440963,592439.5370559038
2022-01-29,False,1445.4390808945325,9964,899.1,2696,2423973.6,1849447.010754491,574526.5892455091
2022-01-30,False,1444.1540175500318,10197,899.1,2770,2490507.0,1886446.0023766824,604060.9976233176
2022-01-31,False,1246.8737599731749,10033,899.1,2745,2468029.5,1873754.1199982178,594275.3800017822
2022-02-01,False,1481.7388652417399,10066,899.1,2730,2454543.0,1866503.6552066077,588039.3447933923
2022-02-02,False,1399.5719382535456,9997,899.1,2704,2431166.4,1853399.9672306762,577766.4327693237
2022-02-03,False,1241.4769716430899,10070,899.1,2704,2431166.4,1853247.3622717985,577919.0377282014
2022-02-04,False,1455.5331575779842,10091,899.1,2760,2481516.0,1881466.3955227518,600049.6044772482
2022-02-05,False,1101.6449199860515,9895,899.1,2717,2442854.7,1859602.5783715304,583252.1216284698
2022-02-06,False,1328.6364164935533,9962,899.1,2817,2532764.7,1909837.6106419214,622927.0893580788
2022-02-07,False,1308.069117200877,10016,899.1,2775,2495002.5,1888820.615166294,606181.8848337061
2022-02-08,False,1132.7159762121048,9861,899.1,2659,2390706.9,1830632.84014718,560074.0598528199
2022-02-09,False,1444.9425958010747,9861,899.1,2716,2441955.6,1859473.3602692473,582482.2397307528
2022-02-10,False,1212.684467045,9972,899.1,2750,2472525.0,1876230.156967209,596294.843032791
2022-02-11,False,1250.5400317812196,9750,899.1,2718,2443753.8000000003,1860258.2671390085,583495.5328609918
2022-02-12,False,1290.0613657717636,9946,899.1,2790,2508489.0,1896301.7101192577,612187.2898807423
2022-02-13,False,1426.7739321889594,10233,899.1,2829,2543553.9,1915938.2627990264,627615.6372009735
2022-02-14,False,1337.9752123091835,10053,899.1,2839,2552544.9,1920840.759277585,631704.140722415
2022-02-15,True,2351.475059441982,18894,790.8822013542945,6744,5333709.565933362,3874358.9633387243,1459350.6025946373
2022-02-16,False,1244.9510303702357,9871,899.1,2774,2494103.4,1888252.9386465398,605850.4613534601
2022-02-17,False,1211.8738687166879,9910,899.1,2711,2437460.1,1856714.7898701457,580745.3101298544
2022-02-18,False,1291.248092774871,9977,899.1,2701,2428469.1,1851817.548661015,576651.5513389851
2022-02-19,False,1202.2934128126344,10133,883.1651108098041,2780,2455199.0080512553,1891207.3343598437,563991.6736914115
2022-02-20,False,1235.804575281713,10084,899.1,2696,2423973.6,1849246.6954483406,574726.9045516595
2022-02-21,False,1276.1505339787307,10085,899.1,2656,2388009.6,1829286.22085432,558723.37914568
2022-02-22,False,1437.4003457574522,9904,899.1,2799,2516580.9,1900942.7903318,615638.1096681999
2022-02-23,False,1472.2042466986154,9964,899.1,2673,2403294.3000000003,1837976.7032677638,565317.5967322364
2022-02-24,False,1431.896547822394,10172,899.1,2743,2466231.3000000003,1872944.902847496,593286.3971525042
2022-02-25,False,1310.2798859572426,10076,899.1,2702,2429368.2,1852330.7801247423,577037.4198752579
2022-02-26,False,1384.62290131771,10043,899.1,2648,2380816.8000000003,1825387.4752716604,555429.3247283399
2022-02-27,False,1234.0834436842747,9702,899.1,2657,2388908.7,1829743.9021500424,559164.7978499578
2022-02-28,False,1283.678769021713,9910,899.1,2682,2411386.2,1842284.07082779,569102.1291722101
2022-03-01,False,1476.1958625388818,10020,899.1,2709,2435661.9,1855990.3574499364,579671.5425500635
2022-03-02,False,1241.9789919979662,9898,899.1,2682,2411386.2,1842256.0852074374,569130.1147925628
2022-03-03,False,1169.1942709029515,9892,899.1,2745,2468029.5,1873673.4418196054,594356.0581803946
2022-03-04,False,1288.837622807191,10030,899.1,2698,2425771.8000000003,1850296.6598978532,575475.1401021471
2022-03-05,False,1361.0366475166352,10010,899.1,2789,2507589.9,1895865.5077794136,611724.3922205863
2022-03-06,False,1150.6057039233983,10086,899.1,2773,2493204.3000000003,1887675.9748459037,605528.3251540966
2022-03-07,False,1148.8405674690443,9990,899.1,2773,2493204.3000000003,1887650.6458073962,605553.6541926041
2022-03-08,False,1221.47795637576,9850,899.1,2726,2450946.6,1864229.4841102757,586717.1158897243
2022-03-09,False,1463.0596405593335,10060,899.1,2781,2500397.1,1891973.8578367615,608423.2421632386
2022-03-10,False,1369.841540397185,10100,899.1,2678,2407789.8000000003,1840391.6702139727,567398.1297860276
2022-03-11,False,1188.773662552044,9895,899.1,2834,2548049.4,1918191.6567640717,629857.7432359282
2022-03-12,False,1341.3950242487674,9934,899.1,2660,2391606.0,1831345.182388721,560260.817611279
2022-03-13,False,1364.0959335247649,10107,899.1,2812,2528269.2,1907376.925745633,620892.2742543672
2022-03-14,False,1309.221871963138,10024,899.1,2726,2450946.6,1864309.6853946745,586636.9146053256
2022-03-15,False,1403.7529842149315,10026,899.1,2746,2468928.6,1874411.3054106305,594517.2945893696
2022-03-16,False,1109.8955954636629,10165,899.1,2802,2519278.2,1902111.2872151928,617166.9127848074
2022-03-17,False,1176.4468908415815,9992,899.1,2683,2412285.3000000003,1842689.52860202,569595.7713979804
2022-03-18,False,1486.5486977700477,10155,899.1,2747,2469827.7,1875005.0228379683,594822.6771620319
2022-03-19,False,1299.096000702733,9897,899.1,2750,2472525.0,1876301.3950001332,596223.6049998668
2022-03-20,True,2959.005898764264,18781,852.3176505002403,5582,4757637.125092342,3293965.8953605895,1463671.229731752
2022-03-21,False,1223.2718760871978,9911,899.1,2742,2465332.2,1872229.5640445976,593102.6359554026
2022-03-22,False,1100.7089544693627,9934,899.1,2697,2424872.7,1849605.1051355922,575267.594864408
2022-03-23,False,1331.7656967542457,9836,899.1,2683,2412285.3000000003,1842832.6021656336,569452.6978343667
2022-03-24,False,1499.7913000398273,10077,899.1,2754,2476121.4,1878519.0568463928,597602.3431536071
2022-03-25,False,1336.0397990084284,10141,899.1,2767,2487809.7,1884850.7572144207,602958.9427855795
2022-03-26,False,1344.0291715257779,9881,899.1,2807,2523773.7,1904848.162184592,618925.5378154081
2022-03-27,False,1231.0906450912316,9917,899.1,2755,2477020.5,1878736.1803134407,598284.3196865593
2022-03-28,False,1194.813018241124,10016,899.1,2799,2516580.9,1900707.1235184686,615873.7764815313
2022-03-29,False,1303.2626288160477,10058,899.1,2790,2508489.0,1896304.5482847781,612184.4517152219
2022-03-30,False,1459.914466790956,10093,899.1,2845,2557939.5,1923968.4508365616,633971.0491634384
2022-03-31,False,1103.9004416458804,9839,899.1,2756,2477919.6,1879111.1779584847,598808.4220415154
16 changes: 10 additions & 6 deletions docs/source/example_notebooks/do_sampler_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"\n",
"## Integration\n",
"\n",
"The do-sampler is built on top of the identification abstraction used throughout do-why. It uses a `dowhy.CausalModel` to perform identification, and builds any models it needs automatically using this identification.\n",
"The do-sampler is built on top of the identification abstraction used throughout do-why. It automatically performs an identification, and builds any models it needs automatically using this identification.\n",
"\n",
"## Specifying Interventions\n",
"\n",
Expand Down Expand Up @@ -128,7 +128,8 @@
"model = CausalModel(df, \n",
" causes,\n",
" outcomes,\n",
" common_causes=common_causes)"
" common_causes=common_causes)\n",
"nx_graph = model._graph._graph"
]
},
{
Expand Down Expand Up @@ -162,8 +163,11 @@
"source": [
"from dowhy.do_samplers.weighting_sampler import WeightingSampler\n",
"\n",
"sampler = WeightingSampler(df,\n",
" causal_model=model,\n",
"sampler = WeightingSampler(graph=nx_graph,\n",
" action_nodes=causes,\n",
" outcome_nodes=outcomes,\n",
" observed_nodes=df.columns.tolist(),\n",
" data=df,\n",
" keep_original_treatment=True,\n",
" variable_types={'D': 'b', 'Z': 'c', 'Y': 'c'}\n",
" )\n",
Expand Down Expand Up @@ -207,7 +211,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -221,7 +225,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
},
"toc": {
"base_numbering": 1,
Expand Down
1,511 changes: 53 additions & 1,458 deletions docs/source/example_notebooks/dowhy-conditional-treatment-effects.ipynb

Large diffs are not rendered by default.

31 changes: 17 additions & 14 deletions docs/source/example_notebooks/dowhy_causal_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"source": [
"import dowhy.datasets\n",
"import dowhy.api\n",
"from dowhy.graph import build_graph_from_str\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
Expand All @@ -36,7 +37,7 @@
" treatment_is_binary=True)\n",
"df = data['df']\n",
"df['y'] = df['y'] + np.random.normal(size=len(df)) # Adding noise to data. Without noise, the variance in Y|X, Z is zero, and mcmc fails.\n",
"#data['dot_graph'] = 'digraph { v ->y;X0-> v;X0-> y;}'\n",
"nx_graph = build_graph_from_str(data[\"dot_graph\"])\n",
"\n",
"treatment= data[\"treatment_name\"][0]\n",
"outcome = data[\"outcome_name\"][0]\n",
Expand All @@ -47,15 +48,17 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# data['df'] is just a regular pandas.DataFrame\n",
"df.causal.do(x=treatment,\n",
" variable_types={treatment: 'b', outcome: 'c', common_cause: 'c'},\n",
" outcome=outcome,\n",
" common_causes=[common_cause],\n",
" proceed_when_unidentifiable=True).groupby(treatment).mean().plot(y=outcome, kind='bar')"
" variable_types={treatment: 'b', outcome: 'c', common_cause: 'c'},\n",
" outcome=outcome,\n",
" common_causes=[common_cause],\n",
" ).groupby(treatment).mean().plot(y=outcome, kind='bar')"
]
},
{
Expand All @@ -68,8 +71,8 @@
" variable_types={treatment:'b', outcome: 'c', common_cause: 'c'}, \n",
" outcome=outcome,\n",
" method='weighting', \n",
" common_causes=[common_cause],\n",
" proceed_when_unidentifiable=True).groupby(treatment).mean().plot(y=outcome, kind='bar')"
" common_causes=[common_cause]\n",
" ).groupby(treatment).mean().plot(y=outcome, kind='bar')"
]
},
{
Expand All @@ -81,14 +84,14 @@
"cdf_1 = df.causal.do(x={treatment: 1}, \n",
" variable_types={treatment: 'b', outcome: 'c', common_cause: 'c'}, \n",
" outcome=outcome, \n",
" dot_graph=data['dot_graph'],\n",
" proceed_when_unidentifiable=True)\n",
" graph=nx_graph\n",
" )\n",
"\n",
"cdf_0 = df.causal.do(x={treatment: 0}, \n",
" variable_types={treatment: 'b', outcome: 'c', common_cause: 'c'}, \n",
" outcome=outcome, \n",
" dot_graph=data['dot_graph'],\n",
" proceed_when_unidentifiable=True)\n"
" graph=nx_graph\n",
" )\n"
]
},
{
Expand Down Expand Up @@ -158,7 +161,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -172,7 +175,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading
Loading