728x90

https://www.inference.vc/causal-inference-3-counterfactuals/

 

Causal Inference 3: Counterfactuals

Counterfactuals are weird. I wasn't going to talk about them in my MLSS lectures on Causal Inference, mainly because wasn't sure I fully understood what they were all about, let alone knowing how to explain it to others. But during the Causality Panel, Dav

www.inference.vc

 

Counterfactuals

 

Conterfactual이라는 용어가 딥러닝 논문에서도 한번씩 나오는데 사실 이해하기 너무 어렵다.

counterfactual의 확률적 용어상의 정의는 다음과 같다.

 - a probablilistic answer to a "what would have happened if" question -

("만약 그랬다면 어떻게 되었을까"라는 질문에 대한 확률적 대답)

 

이번 글에서는 Counterfactual 용어에 대한 이해를 여러가지 예시를 통해 이해해본다.

 

 

Example 1: The election example

 

Given that Hilary Clinton did not win the 2016 presidential election, and given that she did not visit Michigan 3 days before the election, and given everything else we know about the circumstances of the election, what can we say about the probability of Hilary Clinton winning the election, had she visited Michigan 3 days before the election?

(힐러리 클린턴이 2016년 대선에서 승리하지 못했고, 선거 3일 전 미시간주를 방문하지 않았다고 하자. 선거 상황에 대해 아는 모든 것을 감안할 때 힐러리 클린턴이 3일 전 미시간주를 방문했다면 당선 가능성에 대해 어떻게 말할 수 있을까.)

 

이를 해석하면 다음과 같다.

 

Let's try to unpack this. We are are interested in the probability that:

  • she hypothetically wins the election (그녀가 선거에 이길 확률)

conditionied on four sets of things:

  • she lost the election (그녀는 사실은 선거에서 졌다.)
  • she did not visit Michigan (그녀는 미시건에 방문하지 않았다.)
  • any other relevant an observable facts (여러 다른 관측할 수 있는 사건들)
  • she hypothetically visits Michigan ( 만약 그녀가 미시건을 방문했다고 가정했을 때)

 

위의 상황을 보면 힐러리 클린턴이 선거에서 졌는데, 선거에서 이길 확률을 알고 싶어한다던가,

미시건에 사실은 방문하지 않았는데, 방문했다고 가정하는 등, 왜 이런일을 하는지 의문이 들 수 있다.

 

그러나 정치적 분석을 할 때, 왜 힐러리 클린턴이 졌는지 분석한다면, 다음 선거에서 이길 수 있을 것이고,

이러한 이유 때문에 counterfactual 분석을 하게 된다.

 

 

 

Example 2: Counterfactual fairness

 

Given that Alice did not get promoted in her job, and given that she is a woman, and given everything else we can observe about her circumstances and performance, what is the probability of her getting a promotion if she was a man instead?

(앨리스가 직장에서 승진하지 않았고, 그녀가 여자이고, 그녀의 상황과 실적에 대해 우리가 관찰할 수 있는 모든 것을 고려할 때, 그녀가 남자였다면 승진할 가능성은 얼마나 될까요?)

 

이러한 counterfactual question의 특징 중 하나는 바로 specific datapoint에 대한 결과를 질문한다는 것이다.

위의 예에서는 전반적인 승진과정에 대한 fairness를 묻는 것이 아니라, 'Alice' case에 대한 결과만을 묻는다는 것이다.

 

또한 counterfactual은 우리가 실제로는 수행할 수 없거나 힘든 intervention을 포함하고 있다는 것이 또 다른 특징이다.

(위의 예시에서는 Alice는 실제로는 남자가 될 수 없다. 그러므로 남자가 되었을 때의 실험을 수행하는 것은 불가능하다.)

 

 

 

Example 3: My beard and my PhD

 

Given that I have a beard, and that I have a PhD degree, and everything else we know about me, with what probability would I have obtained a PhD degree, had I never grown a beard.

(제가 수염을 기르고 있고, 박사학위도 있고, 저에 대해 알고 있는 다른 모든 것들이 있다고 가정할때, 제가 수염을 기르지 않았다면, 박사학위를 받았을 확률이 얼마나 될까요?)

 

이 예시를 실제로 계산해보기 전에 한번 직관적으로 생각해보자. 수염을 기르는 것과 박사학위를 받는 것과 관련이 있을까? 아마 없을 것이다. 수염을 기르던, 안 기르던 공부는 열심히 했을 것이고, 어찌되었든 박사학위를 받았을 것이다.

그러므로 직관적으로 생각해 봤을때, 위의 예시의 확률을 아마 1에 가까울 것이다.

(수염을 기르지 않았을때, 박사학위를 받았을 확률)

 

 

 

Observational queries

 

다음은 위의 예시의 확률을 살펴보기 위해 수집한 data이다. feature로는 beard, married, fit, PhD가 있다.

 

 

이 data로부터 p(🎓|🧔=0)를 구하면 우리가 원하는 결과를 얻을 수 있을까?

안타깝게도 그건 불가능하다. 우리가 직관적으로 생각했을 때, p(🎓|🧔=0)는 1이 되어야 한다.그러나 위에서 p(🎓|🧔=0)를 계산하면 0.5가 나온다. 물론 데이터양이 충분하다면 이러한 문제는 해결될 수도 있지만,어찌되었든 counterfactual 문제에서 궁금한 인과관계에 대한 해답은 찾을 수 없다.

 

 

intervention queries

 

결론적으로 이 문제를 풀기 위해서 우리가 해야 되는 것은 p(🎓|do(🧔=0))를 구하는 것이다. (not p(🎓|🧔=0))이때 p(🎓|do(🧔=0))를 구하기 위해서는 dataset과 더불어 causal diagram이 필요하다.

 

이렇게 causal diagram이 있으면 우리는 실제로는 불가능하지만 가상으로  distribution을 생성할 수 있다. 위의 예에서는 원래는 수염이 있는 사람들을 수염이 없는 상태로 가상으로 distribution을 만들어 내어서 p(🎓|do(🧔=0))를 계산하고 있다.

 

그러면 p(🎓|do(🧔=0))가 우리가 원하는 counterfactual probability를 설명하는 것이 맞는가? 사실 p(🎓|do(🧔=0))는 counterfactual probability를 설명하는 것은 아니다. 

 

위의 counterfactual probability 예시를 보면 특정 사람 (ex: Alice, me)에 대해서 원하는 상황의 확률 값을 계산하는 것을 볼 수 있다. 그러나 p(🎓|do(🧔=0))의 경우 특정 사람 (me)가 아닌 randomly sampled individual에 대한 확률이다. 

 

 

Counterfactual queries

 

counterfactuals에 대한 설명을 끝내기 위해 stuctural equation models를 소개하려고 한다.

 

stuctural equation models은 causal graph보다 변수간의 관계를 좀 더 explicitly하게 나타낸 그림이다.

(출처 : https://jmlr.org/papers/v14/bottou13a.html)

 

 

위 그림이 나타내는 각 변수간의 관계도는 다음과 같다.

이 SEM (The structural equation model)은 causal graph가 담고 있는 정보를 모두 담고 있으며, intervention 또한 해당되는 function을 제거함으로 표현이 가능하다.

 

 

Back to the beard example

 

 

그러면 SEM 모델을 위의 beaed 예시에 적용해 보면 어떨까?

위 그림과 같이 표현이 가능하다. 위에서 f1이 제거되는 것이 intervention을 의미하며 (수염이 없을 시를 가정하는 것)

왼쪽의 입실론1,2,3가 각 사람에 대한 확률 noise값을 의미한다.

 

이렇게 입실론 변수가 각 사람별로 추가됨으로서, 사람별로 intervention이 적용되었을 때의 결과를 추론하는 확률 모델을 만들 수 있으며, 따라서 우리가 원했던 counterfactual에 대한 확률을 계산하는 모델을 만들 수 있게 된다.

 

결론적으로 counterfactual에 대한 설명은 아래와 같이 할 수 있다.

 

"making a prediction about features of the unobserved twin datapoint based on features of the observed datapoint."

 

수학적으로 나타내면 아래와 같다.

 

p(🎓|🧔=0,🧔=1,💍=1,💪=1,🎓=1)

 

이때, *로 표시된 것이 바로 unobservable variable이다. *가 없는 것은 observable variable이다.

 

 

 

Summary

 

Despite it being untestable, and difficult to interpret, humans make use of counterfactual statements all the time, and intuitively it feels like they are pretty useful for intelligent behaviour. Being able to pinpoint the causes that lead to a particular situation or outcome is certainly useful for learning, reasoning and intelligence. So my strategy for now is to ignore the philosophical debate about counterfactuals, and just get on with it, knowing that the tools are there if such predictions have to be made.

728x90

+ Recent posts