Skip to content

Commit 9fe6b5b

Browse files
조해창조해창
authored andcommitted
fix: markdown cell
1 parent 6aebbe5 commit 9fe6b5b

File tree

1 file changed

+81
-42
lines changed

1 file changed

+81
-42
lines changed

book/scm/causal_discovery.ipynb

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": 289,
26+
"execution_count": 2,
2727
"id": "82d3b359",
2828
"metadata": {},
29-
"outputs": [],
29+
"outputs": [
30+
{
31+
"name": "stderr",
32+
"output_type": "stream",
33+
"text": [
34+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
35+
" from .autonotebook import tqdm as notebook_tqdm\n"
36+
]
37+
}
38+
],
3039
"source": [
3140
"import numpy as np\n",
3241
"import pandas as pd\n",
@@ -64,10 +73,18 @@
6473
},
6574
{
6675
"cell_type": "code",
67-
"execution_count": 290,
76+
"execution_count": 3,
6877
"id": "978da1a6",
6978
"metadata": {},
7079
"outputs": [
80+
{
81+
"name": "stderr",
82+
"output_type": "stream",
83+
"text": [
84+
"/var/folders/fw/d6t_wpzj2zb9lyd3st5l4dfm0000gn/T/ipykernel_39769/3414311417.py:1: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\\s+'`` instead\n",
85+
" data_mpg = pd.read_csv(\n"
86+
]
87+
},
7188
{
7289
"name": "stdout",
7390
"output_type": "stream",
@@ -188,7 +205,7 @@
188205
"4 70.0 1.0 ford torino "
189206
]
190207
},
191-
"execution_count": 290,
208+
"execution_count": 3,
192209
"metadata": {},
193210
"output_type": "execute_result"
194211
}
@@ -210,7 +227,7 @@
210227
},
211228
{
212229
"cell_type": "code",
213-
"execution_count": 291,
230+
"execution_count": 4,
214231
"id": "849d5a67",
215232
"metadata": {},
216233
"outputs": [
@@ -321,7 +338,7 @@
321338
"4 17.0 8.0 302.0 140.0 3449.0 10.5"
322339
]
323340
},
324-
"execution_count": 291,
341+
"execution_count": 4,
325342
"metadata": {},
326343
"output_type": "execute_result"
327344
}
@@ -367,7 +384,7 @@
367384
},
368385
{
369386
"cell_type": "code",
370-
"execution_count": 292,
387+
"execution_count": 5,
371388
"id": "d9267ebd",
372389
"metadata": {},
373390
"outputs": [
@@ -405,7 +422,7 @@
405422
},
406423
{
407424
"cell_type": "code",
408-
"execution_count": 293,
425+
"execution_count": 6,
409426
"id": "e9cff8ed",
410427
"metadata": {},
411428
"outputs": [],
@@ -451,7 +468,7 @@
451468
},
452469
{
453470
"cell_type": "code",
454-
"execution_count": 294,
471+
"execution_count": 7,
455472
"id": "f7f27d2d",
456473
"metadata": {},
457474
"outputs": [
@@ -462,6 +479,30 @@
462479
"LiNGAM adjacency matrix shape: (6, 6)\n"
463480
]
464481
},
482+
{
483+
"name": "stderr",
484+
"output_type": "stream",
485+
"text": [
486+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: divide by zero encountered in matmul\n",
487+
" return X @ coef_ + self.intercept_\n",
488+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: overflow encountered in matmul\n",
489+
" return X @ coef_ + self.intercept_\n",
490+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: invalid value encountered in matmul\n",
491+
" return X @ coef_ + self.intercept_\n",
492+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: divide by zero encountered in matmul\n",
493+
" return X @ coef_ + self.intercept_\n",
494+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: overflow encountered in matmul\n",
495+
" return X @ coef_ + self.intercept_\n",
496+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: invalid value encountered in matmul\n",
497+
" return X @ coef_ + self.intercept_\n",
498+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: divide by zero encountered in matmul\n",
499+
" return X @ coef_ + self.intercept_\n",
500+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: overflow encountered in matmul\n",
501+
" return X @ coef_ + self.intercept_\n",
502+
"/Users/hc.cho/Projects/awesome-causal-inference-python/.venv/lib/python3.10/site-packages/sklearn/linear_model/_base.py:280: RuntimeWarning: invalid value encountered in matmul\n",
503+
" return X @ coef_ + self.intercept_\n"
504+
]
505+
},
465506
{
466507
"data": {
467508
"image/svg+xml": [
@@ -592,10 +633,10 @@
592633
"</svg>\n"
593634
],
594635
"text/plain": [
595-
"<graphviz.graphs.Digraph at 0x345934dc0>"
636+
"<graphviz.graphs.Digraph at 0x10f8b08e0>"
596637
]
597638
},
598-
"execution_count": 294,
639+
"execution_count": 7,
599640
"metadata": {},
600641
"output_type": "execute_result"
601642
}
@@ -613,7 +654,7 @@
613654
},
614655
{
615656
"cell_type": "code",
616-
"execution_count": 295,
657+
"execution_count": 8,
617658
"id": "82938c1e",
618659
"metadata": {},
619660
"outputs": [
@@ -786,15 +827,15 @@
786827
},
787828
{
788829
"cell_type": "code",
789-
"execution_count": null,
830+
"execution_count": 9,
790831
"id": "6d80c7fa",
791832
"metadata": {},
792833
"outputs": [
793834
{
794835
"name": "stderr",
795836
"output_type": "stream",
796837
"text": [
797-
"Depth=3, working on node 5: 100%|██████████| 6/6 [00:00<00:00, 2326.51it/s]"
838+
"Depth=3, working on node 5: 100%|██████████| 6/6 [00:00<00:00, 2269.44it/s]"
798839
]
799840
},
800841
{
@@ -976,10 +1017,10 @@
9761017
"</svg>\n"
9771018
],
9781019
"text/plain": [
979-
"<graphviz.graphs.Digraph at 0x330fbf0a0>"
1020+
"<graphviz.graphs.Digraph at 0x10ae15360>"
9801021
]
9811022
},
982-
"execution_count": 297,
1023+
"execution_count": 9,
9831024
"metadata": {},
9841025
"output_type": "execute_result"
9851026
}
@@ -996,15 +1037,15 @@
9961037
},
9971038
{
9981039
"cell_type": "code",
999-
"execution_count": 298,
1040+
"execution_count": 10,
10001041
"id": "8821657c",
10011042
"metadata": {},
10021043
"outputs": [
10031044
{
10041045
"name": "stdout",
10051046
"output_type": "stream",
10061047
"text": [
1007-
"PC edges (±1은 방향/존재 여부 코드):\n"
1048+
"PC edges:\n"
10081049
]
10091050
},
10101051
{
@@ -1164,7 +1205,7 @@
11641205
" \"weight\", key=lambda s: s.abs(), ascending=False\n",
11651206
")\n",
11661207
"\n",
1167-
"print(\"PC edges (±1은 방향/존재 여부 코드):\")\n",
1208+
"print(\"PC edges:\")\n",
11681209
"display(pc_edges_sorted)"
11691210
]
11701211
},
@@ -1190,7 +1231,7 @@
11901231
},
11911232
{
11921233
"cell_type": "code",
1193-
"execution_count": 269,
1234+
"execution_count": 11,
11941235
"id": "a78c2b78",
11951236
"metadata": {},
11961237
"outputs": [
@@ -1366,10 +1407,10 @@
13661407
"</svg>\n"
13671408
],
13681409
"text/plain": [
1369-
"<graphviz.graphs.Digraph at 0x33547ba90>"
1410+
"<graphviz.graphs.Digraph at 0x10b179630>"
13701411
]
13711412
},
1372-
"execution_count": 269,
1413+
"execution_count": 11,
13731414
"metadata": {},
13741415
"output_type": "execute_result"
13751416
}
@@ -1387,15 +1428,15 @@
13871428
},
13881429
{
13891430
"cell_type": "code",
1390-
"execution_count": 270,
1431+
"execution_count": 12,
13911432
"id": "b627dca4",
13921433
"metadata": {},
13931434
"outputs": [
13941435
{
13951436
"name": "stdout",
13961437
"output_type": "stream",
13971438
"text": [
1398-
"GES edges (±1은 방향/존재 여부 코드):\n"
1439+
"GES edges:\n"
13991440
]
14001441
},
14011442
{
@@ -1555,7 +1596,7 @@
15551596
" \"weight\", key=lambda s: s.abs(), ascending=False\n",
15561597
")\n",
15571598
"\n",
1558-
"print(\"GES edges (±1은 방향/존재 여부 코드):\")\n",
1599+
"print(\"GES edges:\")\n",
15591600
"display(ges_edges_sorted)\n"
15601601
]
15611602
},
@@ -1592,7 +1633,7 @@
15921633
"source": [
15931634
"## Identify and Estimate\n",
15941635
"\n",
1595-
"**weight → mpg** 인과 효과를 추정하는 두 가지 경로를 비교합니다.\n",
1636+
"weight → mpg 인과 효과를 추정하는 두 가지 경로를 비교합니다.\n",
15961637
"\n",
15971638
"1. LiNGAM이 제안한 DAG를 그대로 쓴 경우 \n",
15981639
"2. 도메인 지식으로 구성한 DAG를 쓴 경우"
@@ -1611,7 +1652,7 @@
16111652
},
16121653
{
16131654
"cell_type": "code",
1614-
"execution_count": 299,
1655+
"execution_count": 13,
16151656
"id": "4e568856",
16161657
"metadata": {},
16171658
"outputs": [
@@ -1662,15 +1703,15 @@
16621703
},
16631704
{
16641705
"cell_type": "code",
1665-
"execution_count": 301,
1706+
"execution_count": 20,
16661707
"id": "7a4ab4fb",
16671708
"metadata": {},
16681709
"outputs": [
16691710
{
16701711
"name": "stdout",
16711712
"output_type": "stream",
16721713
"text": [
1673-
"=== Identified estimand (LiNGAM DAG 기반) ===\n",
1714+
"=== Identified estimand LiNGAM DAG ===\n",
16741715
"Estimand type: EstimandType.NONPARAMETRIC_ATE\n",
16751716
"\n",
16761717
"### Estimand : 1\n",
@@ -1715,13 +1756,13 @@
17151756
" proceed_when_unidentifiable=True\n",
17161757
")\n",
17171758
"\n",
1718-
"print(\"=== Identified estimand (LiNGAM DAG 기반) ===\")\n",
1759+
"print(\"=== Identified estimand LiNGAM DAG ===\")\n",
17191760
"print(identified_estimand_lingam)"
17201761
]
17211762
},
17221763
{
17231764
"cell_type": "code",
1724-
"execution_count": 309,
1765+
"execution_count": 21,
17251766
"id": "6c0f9f33",
17261767
"metadata": {},
17271768
"outputs": [
@@ -1759,7 +1800,6 @@
17591800
"estimate_lingam = cm_lingam.estimate_effect(\n",
17601801
" identified_estimand_lingam,\n",
17611802
" method_name=\"backdoor.linear_regression\",\n",
1762-
" # \"weight\"가 1 단위 증가할 때 mpg가 얼마나 변하는지\n",
17631803
" control_value=0,\n",
17641804
" treatment_value=1,\n",
17651805
" confidence_intervals=True,\n",
@@ -1801,12 +1841,12 @@
18011841
" - `horsepower → mpg` (고출력 엔진은 연비가 낮을 가능성)\n",
18021842
"\n",
18031843
"- 출력 → 가속 성능\n",
1804-
" - `horsepower → acceleration` (마력이 높을수록 0–60 시간이 짧아짐)"
1844+
" - `horsepower → acceleration` (마력이 높을수록 가속 시간이 짧아짐)"
18051845
]
18061846
},
18071847
{
18081848
"cell_type": "code",
1809-
"execution_count": 303,
1849+
"execution_count": 22,
18101850
"id": "7e38aff1",
18111851
"metadata": {},
18121852
"outputs": [],
@@ -1842,7 +1882,7 @@
18421882
},
18431883
{
18441884
"cell_type": "code",
1845-
"execution_count": null,
1885+
"execution_count": 23,
18461886
"id": "f3ef518f",
18471887
"metadata": {},
18481888
"outputs": [
@@ -1859,7 +1899,7 @@
18591899
{
18601900
"data": {
18611901
"text/plain": [
1862-
"<dowhy.causal_model.CausalModel at 0x330e3ef50>"
1902+
"<dowhy.causal_model.CausalModel at 0x169ab6110>"
18631903
]
18641904
},
18651905
"metadata": {},
@@ -1880,15 +1920,15 @@
18801920
},
18811921
{
18821922
"cell_type": "code",
1883-
"execution_count": 279,
1923+
"execution_count": 24,
18841924
"id": "a98ee829",
18851925
"metadata": {},
18861926
"outputs": [
18871927
{
18881928
"name": "stdout",
18891929
"output_type": "stream",
18901930
"text": [
1891-
"=== Identified Estimand (Domain DAG) ===\n",
1931+
"=== Identified Estimand Domain DAG ===\n",
18921932
"Estimand type: EstimandType.NONPARAMETRIC_ATE\n",
18931933
"\n",
18941934
"### Estimand : 1\n",
@@ -1923,13 +1963,13 @@
19231963
" proceed_when_unidentifiable=True\n",
19241964
")\n",
19251965
"\n",
1926-
"print(\"=== Identified Estimand (Domain DAG) ===\")\n",
1966+
"print(\"=== Identified Estimand Domain DAG ===\")\n",
19271967
"print(identified_estimand_domain)\n"
19281968
]
19291969
},
19301970
{
19311971
"cell_type": "code",
1932-
"execution_count": 308,
1972+
"execution_count": 25,
19331973
"id": "509fcdca",
19341974
"metadata": {},
19351975
"outputs": [
@@ -1966,7 +2006,6 @@
19662006
"estimate_domain = cm_domain.estimate_effect(\n",
19672007
" identified_estimand_domain,\n",
19682008
" method_name=\"backdoor.linear_regression\",\n",
1969-
" # 동일하게 weight가 1 단위 증가할 때의 효과\n",
19702009
" control_value=0,\n",
19712010
" treatment_value=1,\n",
19722011
" confidence_intervals=True,\n",
@@ -1979,7 +2018,7 @@
19792018
{
19802019
"cell_type": "code",
19812020
"execution_count": null,
1982-
"id": "d4c9560c",
2021+
"id": "b8ec4f40",
19832022
"metadata": {},
19842023
"outputs": [],
19852024
"source": []

0 commit comments

Comments
 (0)