IHDP 데이터셋에 DoWhy 적용하기
가정 방문과 특수 아동 발달 센터 방문이 조산아의 건강 및 발달에 얼마나 영향을 줄까?
작성자: 허현
역자주 - 원문의 내용 자체가 IHDP 데이터셋에 대한 설명이나 인과분석 과정에 대한 설명이 생략되어 있습니다. 해당 문서의 주요 목적은 여러 Propensity Score 방법론과 Refute 방법론을 사용하는 코드 레퍼런스를 남기는 것에 있기 때문에 관련 내용에 대한 학습이 필요한 경우 DOWHY KEY CONCEPTS의 성향점수(Propensity Score)와 추정치를 검증하는 방법를 참고하시면 좋습니다.
# importing required libraries : 필요 라이브러리 불러오기
import dowhy
from dowhy import CausalModel
import pandas as pd
import numpy as np데이터 로드
data= pd.read_csv("https://raw.githubusercontent.com/AMLab-Amsterdam/CEVAE/master/datasets/IHDP/csv/ihdp_npci_1.csv", header = None)
col = ["treatment", "y_factual", "y_cfactual", "mu0", "mu1" ,]
for i in range(1,26):
col.append("x"+str(i))
data.columns = col
data = data.astype({"treatment":'bool'}, copy=False)
data.head()0
True
5.599916
4.318780
3.268256
6.854457
-0.528603
-0.343455
1.128554
0.161703
-0.316603
...
1
1
1
1
0
0
0
0
0
0
1
False
6.875856
7.856495
6.636059
7.562718
-1.736945
-1.802002
0.383828
2.244320
-0.629189
...
1
1
1
1
0
0
0
0
0
0
2
False
2.996273
6.633952
1.570536
6.121617
-0.807451
-0.202946
-0.360898
-0.879606
0.808706
...
1
0
1
1
0
0
0
0
0
0
3
False
1.366206
5.697239
1.244738
5.889125
0.390083
0.596582
-1.850350
-0.879606
-0.004017
...
1
0
1
1
0
0
0
0
0
0
4
False
1.963538
6.202582
1.685048
6.191994
-1.045229
-0.602710
0.011465
0.161703
0.683672
...
1
1
1
1
0
0
0
0
0
0
5 rows × 30 columns
1. Model
2. Identify
3. Estimate (using different methods)
3.1 Using Linear Regression
3.2 Using Propensity Score Matching
3.3 Using Propensity Score Stratification
3.4 Using Propensity Score Weighting
4. Refute
4.1 random_common_cause
4.2 placebo_treatment_refuter
4.3 Data Subset Refuter
Last updated