- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5
Feat/ps dml notebook #19
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
Feat/ps dml notebook #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생 많으셨습니다! 덕분에 전체 흐름이 잘 이해됐습니다.
| "weight = ((data_ps[\"intervention\"]-data_ps[\"propensity_score\"]) /\n", | ||
| " (data_ps[\"propensity_score\"]*(1-data_ps[\"propensity_score\"])))\n", | ||
| "\n", | ||
| "y1 = sum(data_ps.query(\"intervention==1\")[\"achievement_score\"]*weight_t) / len(data)\n", | ||
| "y0 = sum(data_ps.query(\"intervention==0\")[\"achievement_score\"]*weight_nt) / len(data)\n", | ||
| "\n", | ||
| "ate = np.mean(weight * data_ps[\"achievement_score\"])\n", | ||
| "\n", | ||
| "print(\"Y1:\", y1)\n", | ||
| "print(\"Y0:\", y0)\n", | ||
| "print(\"ATE\", np.mean(weight * data_ps[\"achievement_score\"]))" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATE 추정 방식을 하나로 통일하면 어떨까요?
예를 들어 y1 - y0 방식이나, 혹은 np.mean(weight * Y) 방식으로만 계산하는 식으로요.
지금처럼 두 가지 방식을 혼합하면 학습용 예시로 괜찮지만, practical 코드에서는 한 방식으로 고정하는 게 더 깔끔할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 아이디어 감사드립니다! 다음 주에 반영해서 수정해보도록 하겠습니다 :)
| "source": [ | ||
| "data = pd.read_csv(\"./data/learning_mindset.csv\")\n", | ||
| "y = data[\"achievement_score\"]\n", | ||
| "a = data[\"intervention\"]\n", | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처치 변수명이 a와 T로 혼용되고 있는데, 하나로 통일하면 더 깔끔할 것 같습니다.
| "metadata": {}, | ||
| "source": [ | ||
| "위에서 구한 AIPW는 Propensity Score의 Overlap이 충분히 확보되었을 때는 좋은 결과를 나타냅니다. \n", | ||
| "하지만 Overlap 구간이 불안정할 때는 Overlap-weighting = True이라는 기능을 활용해도 좋습니다." | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overlap-weighting=True로 구한 ATO에 대해 궁금한 점이 있습니다!
추정값이 ATE와 꽤 차이가 나는데, overlap 구간이 정량적으로 어느 정도일 때 ATO 추정을 선택하는 것이 적절할까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 아직 공부 중에 있어서 더 정확한 내용은 공부 후 다음 작업 때 업데이트 해두겠습니다 :)
제 개인적인 생각으로는 overlap score가 0.2 ~ 0.3정도 되면 고려해봄직 하다고 판단하고, 실제로 overlap weighting으로 돌려본 후에 결과를 비교해서 타당하다고 생각하는 방법을 따르는게 아닐까 싶습니다.
더불어 ESS(유효표본크기)라는 개념까지 함께 고려해서 전체 N 중 ESS의 비율을 보고 결정하는 경우도 있다고 알고 있습니다.
하지만 위의 값에서 주의해야 할 점은, overlap score가 너무 작다면(Ex. 0.1 이하) overlap weighting을 사용하더라도 해당 분석은 유의미하지 않을 것 같아요(overlap score가 좋은 표본에 weighting이 과도하게 되어, Treatment에 따른 ATE값이 과대계상되는 이슈가 있을 듯 합니다.)
또한 overlap score가 충분히 크더라도 데이터 표본 수가 적으면 그 분석이 타당하다고 보기는 힘들 것 같아요.
즉, overlap 구간과 overlap에 포함되는 데이터의 절대적인 숫자를 모두 고려해서 적절한 방법을 사용해야될 듯 합니다!
지금까지 공부한 걸 바탕으로 제 개인적인 의견에 불과한거라 다음 주에 더 공부해보고 실제 분석에선 어떻게 판단하는지도 내용에 살짝 포함해볼게요 ㅎ
리뷰 감사드립니다!
| "source": [ | ||
| "PS Score를 구할 때 max_iter을 충분히 큰 숫자(1000)으로 설정해 수치 최적화가 수렴할 수 있도록 설정합니다. \n", | ||
| "또한 클리핑을 사용하여 $ \\hat{e} $가 [0.01, 0.99]에서만 존재하도록 극단 가중치를 완화합니다. \n", | ||
| "(use_stabilized = True) " | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(use_stabilized=True)는 설명이 없다면 생략해도 될 것 같습니다.
ATE부분 IPW, AIPW, DR부분 업데이트에 관한 PR입니다.
Matheus Facure에서 사용한 데이터셋을 활용하여 Vanilla IPW, Vanilla AIPW, Overlap-Weighting AIPW를 활용한 ATE 비교(Pywhy 참고)를 진행하였습니다.
추후 같은 데이터셋에서 causalpy에 나와있는 IPW를 구하는 네 가지 방식(raw IPW, Robust IPW(self-normalized), DR IPW(AIPW), Overlap Weighting IPW)에 대한 성능 비교 시각화 코드까지 추가할 예정입니다.
참고
Closes #3