<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pirmin Lemberger on Medium]]></title>
        <description><![CDATA[Stories by Pirmin Lemberger on Medium]]></description>
        <link>https://medium.com/@pirminlemberger?source=rss-aa1fd8f69eaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*AzOiGSJJawRtJrSzybGqfg.jpeg</url>
            <title>Stories by Pirmin Lemberger on Medium</title>
            <link>https://medium.com/@pirminlemberger?source=rss-aa1fd8f69eaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:40:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pirminlemberger/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Perplexity of language models revisited]]></title>
            <link>https://medium.com/data-science/perplexity-of-language-models-revisited-6b9b4cf46792?source=rss-aa1fd8f69eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b9b4cf46792</guid>
            <category><![CDATA[deep-dives]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Pirmin Lemberger]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 13:00:39 GMT</pubDate>
            <atom:updated>2022-06-30T09:17:58.959Z</atom:updated>
            <content:encoded><![CDATA[<h4>From basic information theory to practical computation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSoP9RE3xGhr7Uj2nZCfLg.jpeg" /><figcaption>Source : <a href="https://medium.com/@pirminlemberger/perplexity-of-language-models-revisited-6b9b4cf46792">author</a></figcaption></figure><h4>Still another post on language model perplexity?</h4><p><strong>Language models</strong> (LM) are currently at the forefront of NLP research. Pretrained models based on the Transformer architecture [1] like GPT-3 [2], BERT[3] and its numerous variants XLNET[4], RoBERTa [5]… are commonly used as a foundation for solving a variety of downstream tasks ranging from machine translation to document summarization or open domain question answering. Their zero shot capabilities seem promising and the most daring in the field see them as a first glimpse of more general cognitive skills than the narrowly generalization capabilities that have characterized supervised learning so far [6].</p><p>From a more prosaic perspective LM are simply models for probability distributions <em>p</em>(<em>x</em>₁, <em>x</em>₂, …) over sequences of tokens (<em>x</em>₁, <em>x</em>₂, …) which make up sensible text in a given language like, hopefully, the one you are reading.</p><p>Over the past few years a handful of metrics and benchmarks have been designed by the NLP community to assess the quality of such LM. One option is to measure the performance of a <strong>downstream</strong> task like a classification accuracy, the performance over a spectrum of tasks, which is what the GLUE benchmark does [7]. One can also resort to subjective human evaluation for the more subtle and hard to quantify aspects of language generation like the coherence or the acceptability of a generated text [8]. On the other side of the spectrum, we find <strong>intrinsic</strong>, use case independent, metrics like cross-entropy (CE), bits-per-character (BPC) or perplexity (PP) based on information theoretic concepts. In this short note we shall focus on <strong>perplexity</strong>.</p><p>In a nutshell, the perplexity of a language model measures the degree of uncertainty of a LM when it generates a new token, averaged over very long sequences. Thus, the lower the PP, the better the LM. Obviously, the PP will depend on the specific <strong>tokenization</strong> used by the model, therefore comparing two LM only makes sense provided both models use the same tokenization.</p><p>There is no shortage of papers, blog posts and reviews which intend to explain the intuition and the information theoretic origin of this metric. But dare I say it, except for a few exceptions [9,10], I found this plethora of resources rather confusing, at least for the mathematically oriented minds like mine. The goal of this <strong>pedagogical note</strong> is therefore to build up the definition of perplexity and its interpretation in a streamlined fashion, starting from basic information the theoretic concepts and banishing any kind of jargon. Just good old maths. For proofs, see for instance [11].</p><p><strong>Disclaimer</strong>: this note won’t help you become a Kaggle expert.</p><h4>Entropy and perplexity for a single random variable</h4><p>Simple things first. Let’s recap how we can measure the randomness for a single random variable (r.v.) <em>X</em> taking values <em>x</em> in a finite set 𝒳. You may think of <em>X</em> as a source of textual information, the values <em>x</em> as tokens or words generated by this source and 𝒳 as a vocabulary resulting from some tokenization process. Before going further, lets fix some hopefully self-explanatory notations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyADif4rxzJehXh7hCYn_A.png" /></figure><p>The <strong>entropy</strong> of the source <em>X</em> is defined as (the base of the logarithm is 2 so that <em>H</em>[<em>X</em>] is measured in bits):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uYOBPNqtbtYcgcfQgLjXg.png" /></figure><p>As classical <strong>information theory</strong> [11] tells us, this is both a good measure for the degree of randomness for a r.v. <em>X</em> and, alternatively, it is also a measure of the rate of information produced by the source <em>X</em>. Indeed, if <em>l</em>(<em>x</em>):=|<em>C</em>(<em>x</em>)| stands for the lengths of the encodings <em>C</em>(<em>x</em>) of the tokens <em>x</em> in 𝒳 for a prefix code <em>C </em>(roughly speaking this means a code that can be decoded on the fly) than <strong><em>Shannon’s Noiseless Coding Theorem</em></strong> (SNCT) [11] tell us that the expectation <em>L </em>of the length for the code is bounded below by the entropy of the source:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbAfPrkESuyeNsjsIHZktQ.png" /></figure><p>Moreover, for an optimal code <em>C</em>*, the lengths verify, up to one bit [11]:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbRv8Sc7Buzhs-RvxvG0EA.png" /></figure><p>This confirms our intuition that frequent tokens should be assigned shorter codes. Entropy is a deep and multifaceted concept, therefore we won’t exhaust its full meaning in this short note, but these facts should nevertheless convince the most skeptical readers about the relevance of definition (1). Entropy <em>H</em>[<em>X</em>] is zero when <em>X</em> is a constant and it takes its largest value when <em>X</em> is uniformly distributed over 𝒳:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_tTFWeoKdPkHnglQf5NOg.png" /></figure><p>the upper bound in (2) thus motivates defining <strong>perplexity</strong> of a single random variable as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JL1e4BVaW8Wo-5GoNhvemg.png" /></figure><p>because for a uniform r.v. it simply reduces to the number of cases |𝒳| to choose from. For a non-uniform r.v. <em>X</em> we can interpret PP[<em>X</em>] as an effective uncertainty we face, should we guess its value <em>x</em>. We’ll also need the definitions for the <strong>joint</strong> and <strong>conditional</strong> <strong>entropies</strong> for two r.v. <em>X</em> and <em>Y </em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7PCU88AyBxKU2aTJswUDA.png" /></figure><p>The first definition above readily implies that the entropy is an additive quantity for two independent r.v.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ks1a8G6CQ6fOw-UtyLosKQ.png" /></figure><p>and the second defines the conditional entropy as the entropy of the conditional distribution, averaged over the conditions <em>y</em>. Let’s assume we have an <strong>unknown distribution</strong> <em>P</em> for a source and a <strong>model</strong> <em>Q</em> supposed to approximate it. We then define the <strong>cross-entropy</strong> CE[<em>P</em>,<em>Q</em>] of the source <em>P</em> with respect to the model <em>Q</em> as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoqYxUqjTPkfI6wtKtK4Nw.png" /></figure><p>KL is the well-known <strong>Kullback-Leibler divergence</strong> which is one among several possible definitions of the proximity between probability distributions. Both CE[P,Q] and KL[<em>P</em> ∥<em>Q</em>] have nice interpretations in terms of code lengths. CE is the expectation of the length <em>l</em>(<em>x</em>) of the encodings when tokens <em>x</em> are produced by the source <em>P</em> but their encodings are chosen optimal for <em>Q</em>. Eq. (8) thus shows that KL[<em>P</em>∥<em>Q</em>] is so to say the price we must pay when using the wrong encoding.</p><h4>Entropy and perplexity for a stationary and ergodic process</h4><p>A <strong>stochastic process</strong> (SP) is an indexed set of r.v. For our purposes this index will be an integer which you can interpret as the position of a token in a random sequence of tokens : (<em>X</em>₁, <em>X</em>₂, …). The simplest SP is a set of <strong>i.i.d.</strong> r.v. all drawn from the same distribution <em>P</em>. Assuming we have a sample <em>x</em>₁, <em>x</em>₂, … drawn from such a SP, we can define its <strong>empirical entropy</strong> as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_bcik-GUKjxirAMySvNmYw.png" /></figure><p>The weak <strong>law of large numbers</strong> then immediately implies that the corresponding estimator tends towards the entropy <em>H</em>[<em>X</em>] of <em>P </em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IY0-WCIYzgk1YdrnUoFVNw.png" /></figure><p>In perhaps more intuitive terms this means that for large enough samples we have the approximation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5f9C0jJ_xf9HKYeB9qlpg.png" /></figure><p>or equivalently</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5N0YpelBjrSph81hWRqKsg.png" /></figure><p>Starting from this elementary observation the basic results from information theory can be proven [11] (among which SNCT above) by defining the set of so called typical <strong>sequences </strong>as those whose empirical entropy is not too far away from the true entropy, but we won’t be bothered with these matters here.</p><p>In NLP we are interested in a stochastic source of <strong>non i.i.d</strong>. sequences of r.v. (<em>X</em>₁, <em>X</em>₂, …) because words occurrences within a text that makes sense are certainly not independent. We shall denote 𝜒 such a SP. What then is the equivalent of the approximation (6) of the probability <em>p</em>(<em>x</em>₁, <em>x</em>₂, …) for a long sentences? Actually we’ll have to make a simplifying assumption here regarding the SP 𝜒:=(<em>X</em>₁, <em>X</em>₂, …) by assuming that it is <strong>stationary</strong>, by which we mean that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAAnZj4mAYRu4sLfxwiW7w.png" /></figure><p>for all sequence (<em>x</em>₁, <em>x</em>₂, …) of token and for all <strong>time shifts</strong> <em>t</em>. Strictly speaking this is of course <em>not</em> true for a text document since words a distributed differently at the beginning and at the end of a text. But it is an approximation we have to make to go forward. For such stationary stochastic processes we can think of defining the <strong>entropy rate</strong> (that is the entropy per token) in at least two ways. Here is one which defines the entropy rate as the <strong>average entropy per token</strong> for very long sequences:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inlzFpR2FNtyBW_nLvw_Zg.png" /></figure><p>And here is another one which defines it as the <strong>average entropy of the last token</strong> conditioned on the previous tokens, again for very long sequences:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZi-scaljLrM16mCD40LzQ.png" /></figure><p>The whole point of restricting our attention to stationary SP is that it can be proven [11] that these two limits coincide and thus provide us with a good definition for the entropy rate <em>H</em>[𝜒] of stationary SP 𝜒.</p><p>At last we can then define the perplexity of a stationary SP in analogy with (3) as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmH27f7JDVwdV-M8NaNWig.png" /></figure><p>The interpretation is straightforward and is the one we were trying to capture from the beginning. It is the <strong>uncertainty per token</strong> of the stationary SP 𝜒. Is there an approximation which generalizes equation (7) for stationary SP? Unfortunately, in general <em>there isn’t</em>! We must make an additional technical assumption about the SP 𝜒. Namely, we must assume that the SP 𝜒 is <strong>ergodic</strong>. A detailed explanation of ergodicity would lead us astray, but for the interested reader see chapter 16 in [11]. Very roughly, the ergodicity condition ensures that the expectation 𝔼[<em>X</em>₁] of any single r.v. <em>X</em>₁ over the distribution <em>P</em> of the process 𝜒 can be replaced with the time average of a single very long sequence (<em>x</em>₁, <em>x</em>₂, …) drawn from 𝜒 (<strong><em>Birkoff’s Ergodic Theorem</em></strong>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lyAzXE_-01R4oCR3sYmuw.png" /><figcaption>For an ergodic process the srong law of large number holds.</figcaption></figure><p>So if we assume that our source 𝜒 is indeed both stationary and ergodic (which is probably only approximately true in practice for text) then the following generalization of (7) holds (<strong><em>Shannon, McMillan, Breiman Theorem </em></strong>(SMB) [11]):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsXIX7Tr9sjM91SgB5ubYg.png" /></figure><p>Thus we see that to compute the entropy rate <em>H</em>[𝜒] (or the perplexity PP[𝜒]) of an ergodic process 𝜒 we only need to <strong>draw one single very long sequence</strong>, compute its negative log probability and we are done! No need to perform huge summations. So let’s rejoice! The intuition behind (11) is that, in a way, an infinitely long sequence actually contains them all.</p><h4>Bounding the perplexity of an unknown process</h4><p>All this would be perfect for calculating the entropy (or perplexity) of a language like English if we knew the corresponding probability distributions <em>p</em>(<em>x</em>₁, <em>x</em>₂, …). But unfortunately we don’t and we must therefore resort to a language model <em>q</em>(<em>x</em>₁, <em>x</em>₂, …) as an approximation. Fortunately we will be able to construct an upper bound on the entropy rate for <em>p</em>. This upper bound will turn out to be the <strong>cross-entropy</strong> of the model <em>Q </em>(the language model) with respect to the source <em>P</em> (the actual language). It is defined in direct analogy with the entropy rate of a SP (8,9) and the cross-entropy of two ordinary distributions (4):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ul_EpZSqiZkyhPulWUUGoA.png" /></figure><p>It is thus the uncertainty per token of the model <em>Q</em> when facing token produced by source <em>P</em>. The second equality is a theorem similar to the one which establishes the equality between (8) and(9) for the entropy rate . The promised bound on the unknown entropy of the langage is then simply [9]:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5oKcb8DAW3QuR1_btKMvFA.png" /></figure><p>At last, the <strong>perplexity of a model</strong> <em>Q</em> for a language regarded as an unknown source SP <em>P</em> is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTtflVP7ncCdLNeGG77zvw.png" /></figure><p>In words: the model <em>Q</em> is as uncertain about which token occurs next, when generated by the language <em>P</em>, as if it had to guess among PP[<em>P</em>,<em>Q</em>] options. To compute PP[<em>P</em>,<em>Q</em>] or CE[<em>P</em>,<em>Q</em>] we can use an extension of the SMB-Theorem [9]:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x9yWt2R0GCsh9xm4FjU46g.png" /></figure><h4>At last: the perplexity of a Language Model</h4><p>Assume for concreteness that we are given a language model whose probabilities <em>q</em>(<em>x</em>₁, <em>x</em>₂, …) are defined by an RNN like an LSTM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2VnABvR56ab8qK9N-vLkOw.png" /></figure><p>The SMB result (13) then tells us that we can estimate CE[<em>P</em>,<em>Q</em>] by sampling any long enough sequence of tokens and by computing its log probability . Plugging the explicit expression for the RNN distributions (14) in (13) to obtain an approximation of CE[<em>P</em>,<em>Q</em>] in (12), we finally obtain the explicit <strong>formula for the perplexity of a language model</strong> <em>Q</em> with respect to a language source <em>P</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YSqDq3LCd34k87dxQyNQ7A.png" /></figure><p>As an example of <strong>a numerical value</strong>, GPT-2 achieves 1 bit per character (=token) on a Wikipedia data set and thus has a <strong>character perplexity</strong> 2¹=2. The average length of english words being equal to 5 this rougly corresponds to a <strong>word perplexity</strong> equal to 2⁵=32.</p><h4>Practical computation of perplexity</h4><p>The length <em>n</em> of the sequences we can use in practice to compute the perplexity using (15) is limited by the maximal length of sequences defined by the LM. GPT-2 for example has a maximal length equal to 1024 tokens. The best thing to do in order to get reliable approximations of the perplexity seems to use <strong>sliding windows</strong> as nicely illustrated <a href="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/ppl_sliding.gif">here</a> [10]. For improving performance a stride large than 1 can also be used. The Hugging Face documentation [10] has more details.</p><p>Et voilà !</p><h4>References</h4><p>[1] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin, <em>Attention is All you Need</em>, Advances in Neural Information Processing Systems 30 (NIPS 2017).</p><p>[2] Tom Brown et al. <em>Language Models are Few-Shot Learners</em>, Advances in Neural Information Processing Systems 33 (NeurIPS 2020).</p><p>[3] Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova, <em>BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</em>, Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers).</p><p>[4] Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R. Salakhutdinov, Quoc V. Le, XLNet: <em>Generalized Autoregressive Pretraining for Language Understanding</em>, Advances in Neural Information Processing Systems 32 (NeurIPS 2019).</p><p>[5] Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, Veselin Stoyanov, <em>RoBERTa: A Robustly Optimized BERT Pretraining Approach, </em><a href="https://arxiv.org/abs/1907.11692">arxiv.org/abs/1907.11692</a> (2019).</p><p>[6] Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, Yusuke Iwasawa, <em>Large Language Models are Zero-Shot Reasoners</em>, <a href="https://paperswithcode.com/paper/large-language-models-are-zero-shot-reasoners">papers with code</a> (May 2022)</p><p>[7] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, Samuel R. Bowman, <em>GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding</em>, <a href="https://arxiv.org/abs/1804.07461">arXiv:1804.07461</a>.</p><p>[8] Long Ouyang et al. <em>Training language models to follow instructions with human feedback</em>, <a href="https://arxiv.org/abs/2203.02155">https://arxiv.org/abs/2203.02155</a> (March 2022)</p><p>[9] Peter F. Brown, Vincent J. Della Pietra, Robert L. Mercer, Stephen A. Della Pietra, Jennifer C. Lai, <em>An Estimate of an Upper Bound for the Entropy of English,</em>Computational Linguistics, Volume 18, Issue 1, March 1992.</p><p>[10] Hugging Face documentation, <a href="https://huggingface.co/docs/transformers/perplexity#perplexity-of-fixedlength-models"><em>Perplexity of fixed-length models</em></a>.</p><p>[11] Thomas M. Cover, Joy A. Thomas, <em>Elements of Information Theory, 2nd Edition</em>, Wiley 2006.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b9b4cf46792" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/perplexity-of-language-models-revisited-6b9b4cf46792">Perplexity of language models revisited</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reconciling Causality and Statistics]]></title>
            <link>https://medium.com/data-science/reconciling-causality-and-statistics-1dfa4ce1b465?source=rss-aa1fd8f69eaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dfa4ce1b465</guid>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[causality]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Pirmin Lemberger]]></dc:creator>
            <pubDate>Fri, 10 Jul 2020 14:55:08 GMT</pubDate>
            <atom:updated>2020-09-23T16:44:48.958Z</atom:updated>
            <content:encoded><![CDATA[<h4>An Introduction to Pearl’s do Calculus Illustrated with Business Examples</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfPAEvLwoU0QXYlZoPbfjg.jpeg" /><figcaption><a href="https://photos.app.goo.gl/a1BjXQkFTSeRV5ac7">source</a> : author</figcaption></figure><p><em>This is joint work by </em><a href="https://www.linkedin.com/in/pirminlemberger/"><em>Pirmin Lemberger</em></a><em> and </em><a href="https://www.linkedin.com/in/denisoblin/"><em>Denis Oblin</em></a><em>.</em></p><ol><li><strong>A Stormy Relationship</strong></li><li><strong>The Causal Revolution in a Nutshell</strong></li><li><strong>Causal Analysis of Simple Business Examples</strong></li><li><strong>Stuff Worth Knowing for Data Scientists?</strong></li></ol><h3>1. A Stormy Relationship</h3><p>Consider the following three pairs of concomitant events: “<em>the sun rises shortly after the first crow of the rooster”</em>, “<em>the number of visits to some website tends to increase when an ad banner is shown in some appropriate location</em>’’ and “<em>the rate of skin cancer parallels the sale of ice creams on the French Riviera</em>’’.</p><p>While common sense dictates that there is little chance to reduce cancer by limiting ice cream sales or to speed up sunrise by tickling the rooster so it crows earlier, it is not unlikely though that trying to optimize the position of an ad banner might indeed be worth the effort. So it seems our intuition about how the world works tells us something about these concomitant events which goes beyond what mere statistics can describe. Statistics indeed only deals with correlation, meaning it quantifies how likely it is that an event B will occur assuming that we have observed another event A. It tells us nothing however about what happens if we act on a system and it even provides no means to describe what an intervention on a system is. The conclusion is thus straightforward: in general, we need more than just probability and statistics to express and answer causality questions. The method of <strong>Randomized Controlled Trials</strong> (RCT) which entirely rests on statistic analysis and is widely recognized as the gold standard for clinical trials is one noteworthy exception that we shall have more to say about later on.</p><p>The innate inability of plain statistics to properly deal with causality in all its generality has only been recognized at the turn of this century [1]. Before that, a controversy had been going on for nearly one century. We won’t enter these lengthy debates because fortunately nowadays there is no reason for controversy anymore! The pioneering work of Judea Pearl [1,2,3], a philosopher and statistician, has put a definitive end to these quarrels by providing a mathematically sound framework that allows both to formulate causality questions in an unambiguous way and to answer them systematically whenever this is possible [3]. Judea Pearl is largely responsible for a complete reshaping of the causality debate, which has since then been termed the <strong>Causal Revolution</strong>. For this and his other outstanding achievements on causal reasoning in AI, he was awarded the Turing prize in 2011.</p><p>Before we dive into the subtleties of Judea Pearl’s conceptions of causality, let’s acknowledge that many data scientists who use <strong>supervised machine learning</strong> as their favorite tool never bother about causality issues. As a matter of fact, they could run into serious trouble because of this but it is nevertheless a legitimate attitude in two common situations that we briefly mention.</p><ul><li>First, it could be that discovering a correlation between two type of events has value in its own right. For instance learning that users who bought product A are also likely to buy product B can provide some insight into a population of customers. The important point is that any subsequent action driven by such a correlation based prediction should not retro-act in any way on the measured variables.</li><li>Second, there are other situations where a passive observation of some feature <em>X</em> has indeed the same effect (on predicting a target variable <em>Y</em>) as an intervention where we prescribe the value of that feature. Imagine for instance that <em>X</em> is the rotation speed of an air pump and <em>Y</em> is the pressure it maintains in a room. Once we have learned the relation between <em>X</em> and <em>Y</em> by passive observations, we will be able to predict the air pressure when we set the speed of the pump. Intuitively, the causal relationship from <em>X</em> to <em>Y</em> is direct and unperturbed. We will precisely characterize theses situations in section 2.4 when we describe the do Calculus.</li></ul><p>Where Judea Pearl’s approach really shines is in less obvious situations where we would like to infer the effect of setting <em>X</em>=<em>x</em> on the value of <em>Y</em> in the presence of a whole network of causal relationships that involves other variables <em>Z</em>. These other variables are often called <strong>concomitants</strong> [4] and may be observed or not. In its simplest version, the root of the difficulty in answering causal questions is depicted in figure 1 which illustrates the notion of a <strong>confounder</strong> <em>Z</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*s16q3Stseha0lYWYY4AblQ.png" /><figcaption><strong>Figure 1</strong>: Suppose X<em> </em>designates the choice to administer a medicine to a patient, Y is the state of health of that patient and Z his or her age. If a doctor chooses to whom he or she administers the treatment, then the age Z could become a confounder impacting both the choice X of the treatment and the health state Y.</figcaption></figure><p>In intuitive terms, a confounder <em>Z</em> is a variable that could potentially hinder the identification of a causal relationship between two other variables <em>X</em> and <em>Y</em> by being a cause of both. An observed change in the value of <em>Y</em> that results from a change of <em>X</em> could just as well be attributed to a change of <em>Z</em>. Yet, if had access to the values of the confounder <em>Z</em>, we could perhaps adjust for its effect and thus extract the desired effect of <em>X</em> on <em>Y</em>. The procedure for doing this, when it is possible, is well known to statisticians and goes under the name “<strong>controlling</strong> for <em>Z</em>’’. In a nutshell, what Pearl’s machinery achieves is a vast generalization of this controlling procedure:</p><blockquote>Pearl’s graphic and algebraic tools allow the identification of situations in which we may possibly disambiguate a causal relationship between two variables <em>X</em> and Y. Wherever this is possible these tools provide explicit formulas for computing the effect on a variable Y of an intervention that prescribes the value x of another variable X. These formulas merge two kinds of information. First, they uses the values of some concomitants Z which are just observed. Second, they leverage a causal graph G which encapsulates our knowledge of the causal relationships between the variables within a system of interest.</blockquote><p>Later we shall consider still another way to interpret Pearl’s work namely as a vast generalization of RCT’s.</p><p>Pearl’s conceptual and computational tools have several important merits:</p><ul><li>From a practical point of view, they allow to <strong>anticipate the effect of an intervention</strong> on a system without actually having to perform any action on it. This is obviously extremely useful in situations where we cannot afford to act on a system, whether for ethical or financial reasons.</li><li>Still from a practical point of view, they all to <strong>integrate causal prior knowledge</strong> about a system with measurements in a fully consistent manner.</li><li>From a conceptual standpoint, they provide clear definitions of what is meant by a causal influence and by an intervention, as we shall see shortly. This <strong>settles the secular causality controversy</strong> and reconciles statistics with causality.</li></ul><p>The sequel of this article is organized as follows. Section 2 introduces the main concepts and tools defined by Pearl and coworkers. After a brief review of <strong>Bayesian networks</strong> which allows us to introduce the notion of <em>d–</em><strong>separation</strong>, we define what a <strong>functional causal model</strong> is and describe the extent to which it can be inferred from data. We define the notions of <strong>intervention</strong> and of <strong>identifiability</strong>. We explain the graphical <strong>back-door</strong> and <strong>front-door</strong> criteria that allow to identify causal effects in some specific circumstances. At last, we introduce the rules of the <strong>do Calculus</strong> that are even more flexible. Section 3 discusses various business examples as illustrations. The last section offers some concluding remarks and tries to explain why in our opinion these tools still remain little known within the data scientist community at large.</p><h3>2. The Causal Revolution in a Nutshell</h3><p>In this section, we will present the main <strong>definitions</strong> and <strong>mathematical results</strong> underpinning the Causal Revolution. We define what <strong>causal relationships</strong> are, how and when we can identify them from data. Then we define what an <strong>intervention</strong> is and describe the graphical and algebraic tools which allow to identify situations where we can compute the consequences of an intervention using data collected from pure observation. For proofs, we refer to Pearl’s book on Causality [2] and to the original papers [3].</p><h4>2.1 Bayesian Networks Recap</h4><p>The tools we shall present in the following subsections rely heavily on a graphical method called the <em>d</em>-<strong>separation criterion</strong> that allows answering general independence questions among groups of random variables (r.v). These tools were pioneered by Pearl who developed the concept of a <strong>Bayesian Network</strong>. There are many good textbooks on this topic [9] but we provide a brief introduction both to introduce notations and to make the presentation reasonably self-contained. Readers familiar with this material are invited to jump to subsection 2.2.</p><p>We use upper case letters like <em>X</em>, <em>Y</em> or <em>Z</em> to designate r.v. and boldface upper case to denote sequences (or sets) of r.v <strong>X</strong>=(<em>X</em>_1, <em>X</em>_2,…, <em>X</em>_m), with lower indices to denote the components of <strong>X</strong>. For simplicity we shall assume that each component takes only a finite number of values. The corresponding realizations of these r.v. will be denoted with corresponding lower case letters <strong>x</strong>=(<em>x</em>_1, <em>x</em>_2,…, <em>x</em>_<em>m</em>).</p><p>The first step is to associate a graph <em>G</em> to a probability distribution <em>p</em>(<strong>x</strong>)=<em>p</em>(<em>x</em>_1, <em>x</em>_2,…, <em>x</em>_<em>m</em>). Iterating the product rule for conditional probabilities we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*cH7rtApjGTIX7Xh6jEis_w.png" /></figure><p>where the conditioning set for <em>j</em>=1 is empty. Now if <em>X</em>_<em>j</em> is only conditioned on a subset of <em>X</em>_1,…,<em>X</em>_j-1, let’s denote the minimal such subset by PA_j, the <strong>parents</strong> of <em>X</em>_<em>j</em>, so that we can write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*miX7_QWca91WR1qRfx0_Yw.png" /></figure><p>A natural representation of (2) is to use a <strong>Bayesian network</strong> which is a <strong>directed acyclic graph</strong> (DAG) where each node of the graph corresponds to a variable <em>X</em>_<em>j</em> and a directed link points from each member of PA_<em>j</em> towards <em>X</em>_<em>j</em> as figure 2 shows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*kyR-i_26XqbP1XjQU85K5A.png" /><figcaption><strong>Figure 2 </strong>: A unique DAG G can be associated to a probability distribution p on an ordered set or r.v. X_1,…,X_n.</figcaption></figure><p>We say that the probability distribution <em>p</em> and the graph <em>G</em> are <strong>compatible</strong>. Note also that according to (1) the DAG associated to a generic distribution <em>p</em> with no specific factorization properties is a fully connected graph. Hence all information in a DAG is really contained it the missing links.</p><p>For a given order of the r.v. this graph <em>G</em> is unique. However, if we had chosen another order for the r.v. in <em>p</em> we would have obtained another graph <em>G’</em>. Therefore, the natural question that arises is to determine when two DAG <em>G</em> and <em>G’</em> <strong>observationally equivalent</strong>. More precisely we want to ask whether any probability distribution <em>p</em> which is compatible with <em>G</em> is also compatible with another graph <em>G’</em>. The following can be shown [2]:</p><p><strong>Theorem 1</strong>(observational equivalence): <em>Two DAG’s are observationally equivalent if two conditions are met. First the graphs that result from stripping of the arrows on the edges of G and G’ (their skeletons) should be the same. Second, G and G’ should have the same v-structures, which are nodes with converging arrows whose tails are not connected by an arrow.</em></p><p>Let <strong>X, Y</strong> and <strong>Z</strong> be three groups of r.v. whose joint distribution is <em>p</em>(<strong>x</strong><em>,</em><strong>y</strong><em>,</em><strong>z</strong>). Of particular interest is the question whether <strong>X</strong> is independent of <strong>Y</strong> conditionally on observing <strong>Z</strong>, that is whether</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*N4PkIlMMjpdSnfQkiEytXg.png" /></figure><p>or, equivalently, whether</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*E4pCkMu-ymEeHyfpriusAw.png" /></figure><p>When the answer is yes, we denote this by (<strong>X</strong> ‘indep of’ <strong>Y</strong> | <strong>Z</strong>). The <em>d</em>-separation theorem below allows us to answer this question graphically by looking at the graph <em>G</em> associated to <em>p</em>. For this we need the following graphical concept:</p><p><strong>Definition 1</strong>: A path <em>γ </em>(a sequence of consecutive edges oriented in any direction) in a DAG <em>G</em> is said to be blocked by a set of nodes <strong>Z</strong> if and only if one of the following two conditions is met:</p><ul><li>The path <em>γ</em> contains a <strong>chain</strong> (<em>i</em> → <em>m</em> → <em>j</em>) or a <strong>fork</strong> (<em>i</em> ← <em>m</em> → <em>j</em>) such that <em>m</em> belongs to <strong>Z</strong>.</li><li>The path <em>γ</em> contains a <strong>collider</strong> (<em>i</em> → <em>m</em> ← <em>j</em>) such that neither <em>m</em> nor any of its descendants (as defined by the arrows on the edges in <em>G</em>) belongs to <em>Z</em>.</li></ul><p>A set <strong>Z</strong> is said to <em>d</em>-separate <strong>X</strong> from <strong>Y</strong> whenever <strong>Z</strong> blocks every path from a node in <strong>X</strong> to a node in <strong>Y</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*MY0tXtN0daAhmP1Q3qlNrA.png" /><figcaption><strong>Figure 3 </strong>: Observed nodes are depicted as filled circles. In (a) the path from X to Y is neither blocked by Z_2, because it is an observed descendant of the collider Z_1, nor is it by Z_3 which is an unobserved fork. In (b) the path from X to Y is blocked by Z_3 because it is an observed fork.</figcaption></figure><p>We can now formulate the <em>d</em>-separation criterion which relate the factorization properties of <em>p</em> described by a compatible DAG <em>G</em> and the independence relationships they imply:</p><p><strong>Theorem 2 </strong>(<em>d</em>-separation theorem): <em>Let </em><strong>X</strong><em>,</em><strong>Y</strong><em>,</em><strong>Z</strong><em> be three disjoint sets of nodes in a DAG G compatible with a distribution p. Then the corresponding r.v. distributed according to p satisfy </em><strong>X</strong><em> ‘</em>indep of<em>’ </em><strong>Y </strong><em>| </em><strong>Z</strong><em> whenever </em><strong>X</strong><em> and </em><strong>Y</strong><em> are d-separated by </em><strong>Z</strong><em>.</em></p><p>The converse is true as well. An important consequence from theorem 2 is that the set of conditional independence among r.v. is determined by the <strong>topology</strong> of <em>G</em> only, while the ordering of the r.v. plays no role. When we consider the <em>d</em>-separation criterion as a graphical test on the nodes of a DAG <em>G</em> we shall write (<strong>X</strong> ‘indep of’ <strong>Y </strong>| <strong>Z</strong>)_<em>G</em>. Using (4) we can then rewrite theorem 2 compactly as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*cCxTjS3FuJMVfNnr2EUzmA.png" /></figure><p>We insist that that so far there has been no discussion of causality, only independence questions were examined. There is however an easy <strong>mnemonic</strong> for the <em>d</em>-separation criterion if we momentarily allow ourselves to associate a causal meaning to the arrows in <em>G</em>. Indeed, if we fix the value of the middle node <em>m</em> in a chain or a fork we block the information flow between the two end nodes <em>i</em> and <em>j</em> which thus become independent. If, on the contrary, we observe the value of a collider node <em>m</em>, or of some of its descendants, we actually observe a common consequence of <em>i</em> and <em>j</em>. Knowing both <em>i</em> and <em>m</em> for example will thus tell us something about <em>j</em>, which thus opens the information flow. This independence analysis based on <em>d</em>-separation prefigures the genuine causal analysis we develop in the next subsections.</p><h4>2.2 Functional Causal Models and Interventions</h4><p><strong><em>Structural Equations</em></strong></p><p>A conditional probability <em>p</em>(<strong>y</strong>|<strong>x</strong>) tells us how the probability of seeing <strong>Y</strong>=<strong>y</strong> is affected by having observed that <strong>X</strong>=<em>x</em>. It tells us nothing however about what happens when we prescribe the value of <strong>X</strong>. To answer that question we need more information than <em>p</em> contains, namely information about how the probabilistic model <em>p</em> will change under an external intervention. This is precisely what a <strong>functional causal model</strong> <em>M</em> does. It is defined as a set of functional relationships which describe how each r.v. <em>X</em>_<em>j</em> is determined as a function of the others and of some noisy disturbances. It thus explains how the data is generated. Using the notation PA_<em>j</em> to denote the set of r.v. that directly influence <em>X</em>_<em>j</em>, a causal model is then defined as a set of <strong>structural equations</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*V7tlX-BqZRB8bhORH1UsPw.png" /></figure><p>where the <em>f</em>_<em>j</em>’s are deterministic functions of both the parents variables PA_<em>j</em> and some noisy disturbance ϵ_<em>j</em>. An important point is that the ϵ should be independent. In other words each relation is assumed to be disturbed by a single random perturbation. If a perturbation were to affect several r.v. simultaneously, we should promote it to an unobserved <em>X</em>_<em>j</em> with a structural equation describing its influence on other variables. A causal graph <em>G</em> can be associated to a causal model <em>M</em> as shown in figure 4 which also defines the notion of a <strong>confounding arc</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*o2ZtvycfjbEIODjSN5vowg.png" /><figcaption><strong>Figure 4: </strong>A causal graph G where observed r.v. like X,Y or Z are represented as full circles, while unobserved r.v. like U_1 or U_2 are represented as empty circles. A confounding arc is a path which joins two observed r.v., contains only unobserved r.v. and has no converging arrows.</figcaption></figure><p>The probability distribution <em>p</em> on a set of r.v. <strong>X</strong> is completely specified by the model <em>M</em> which comprises the set of deterministic functions <em>f</em>_<em>j</em> and the distributions of the disturbances ϵ. In practice, these will, however, remain unspecified. Beware that the links in figure 2 represent conditional dependencies <em>p</em>(<em>x</em>_<em>j</em>|pa_<em>j</em>) while they represent deterministic dependencies <em>x</em>_<em>j </em>= <em>f</em>_<em>j</em>(pa_<em>j</em>, ϵ_<em>j</em>) in figure 4.</p><p>Assume that we are given a causal graph <em>G</em> associated with a causal model <em>M</em> which generates a probability distribution <em>p</em>. What independence relationships hold for this <em>p</em>? The answer is as simple as we could have dreamed: they are precisely those determined by the <em>d</em>-separation criterion applied to <em>G</em>. This follows from the fact that <em>p</em> is compatible with <em>G</em> in the Bayesian network sense and from the <em>d</em>-separation theorem.</p><p><strong><em>The do-Operator</em></strong></p><p>An <strong>intervention</strong> on a system described by a causal model is an alteration of the structural equations (6) where some relationships are replaced by others. In the simplest case where we fix the value of, say, <em>X</em>_<em>i</em> to <em>a</em> this amounts to replacing the equation <em>X</em>_<em>i</em>=<em>f</em>_<em>i</em>(PA_<em>i</em>, ϵ_<em>i</em>) with <em>X</em>_<em>i</em>=<em>a</em>. The corresponding causal graph of the modified model is thus obtained from <em>G</em> by removing all links connecting the nodes to <em>X</em>_<em>i</em> to their parents PA_<em>i</em> as figure 5 shows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7aEfk84zI9sf3aO9QZNYg.png" /><figcaption><strong>Figure 5 </strong>: Removing the links between the variable X_4 and its parents PA_4 to define an intervention. If (a) represents p(<strong>x</strong>), then (b) represents p(<strong>x</strong>|do(x_4=a)).</figcaption></figure><p>After the intervention, the probability distribution <em>p</em>(<strong>x</strong>)<strong> </strong>is replaced by a new one which we denote by <em>p</em>(<strong>x</strong>|do(<em>x</em>_<em>i</em>=<em>a</em>)). This defines the <strong>do operator</strong>. Using this definition and the factorization (1) for the distribution <em>p</em> we can also express the post intervention distribution as a truncated factorization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*YdhdVMmPmYT5Wr1HEENN1g.png" /></figure><p>In general <em>p</em>(<strong>x</strong>|do(<em>x</em>_<em>i</em>=<em>a</em>)) is of course different from the classical conditional <em>p</em>(<strong>x</strong>|<em>x</em>_<em>i</em>=<em>a</em>). One trivial case where both expressions are indeed identical is when <em>X</em>_<em>i</em> has no parents that is PA_<em>i </em>is the empty set. The general question of when an action on a variable <em>X</em> has the same consequence on another variable <em>Y</em> as an observation will be answered precisely when we present the do-calculus in section 2.4.</p><p>To get more intuition about the do-operator let’s compute the effect of an intervention do(<em>x</em>_<em>i</em>=<em>a</em>) on a single variable <em>Y</em> which is different from both <em>X_i</em> and its parents PA_<em>i</em>. Plugging</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*N5yrBa4x_O9Do-LP96RCZg.png" /></figure><p>into (7) for <em>x</em>_<em>i</em>=<em>a</em> and marginalizing over all variables except on <em>y</em> and on <em>x_i</em> we obtain</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*bbJpknj8noBTTUEMof3Wgg.png" /></figure><p>This conditioning and weighting operation (9) on the variables PA_<em>i</em> to compute <em>p</em>(<em>y</em>|do(<em>x</em>_<em>i</em>=<em>a</em>)) is known as <strong>adjusting</strong> for the <strong>direct causes</strong> of <em>X_i</em>.</p><p>Equation (9) shows that when the parents PA_<em>i</em> of a manipulated variable <em>X_i</em> are measurable, then the effect on <em>Y</em> of an intervention on <em>X_i</em> can be computed from passive observations only. Indeed these determine both <em>p</em>(<strong>x</strong>) and <em>p</em>(<em>x</em>_<em>i</em>|pa_<em>i</em>). In practice we could use machine learning for this purpose.</p><p>The interesting question then is whether we can compute the effect of an intervention when this is not the case, that is when some of the r.v. in PA_<em>i</em> are <em>not</em> measurable? More generally, the question that naturally arises is then the following. Given a causal graph <em>G</em> and a subset <strong>Z</strong> of observable concomitants can we express <em>p</em>(<em>y</em>|do(<em>x</em>=<em>a</em>)) in terms of the distribution on the observed variables <strong>Z</strong>, <em>X</em> and <em>Y</em> only? When this is the case we shall say that the causal effect of <em>X</em> on <em>Y</em> is <strong>identifiable</strong>. Let’s compactly summarize this concept of identifiability [11].</p><blockquote>Passive observation of the variables X and Y and a group <strong><em>Z</em></strong> of observable concomitants informs us on their joint distribution p<em>(</em>x,y,<strong><em>z</em></strong><em>)</em>, as long as we have enough data of course. However, the effect p<em>(</em>y|<em>do(</em>x<em>))</em> on Y of an intervention on X is only encoded in the causal model M which generates this p, but not in p itself! The problem we thus face is that two different causal models M_1 and M_2 could generate the same p. To predict the effect of an intervention we thus need more information than is contained in p. The causal graph G associated to the causal model M can sometimes provide this missing information, without the need for a complete knowledge of the causal model M. When this is the case, we say that the intervention p<em>(</em>y|<em>do(</em>x<em>))</em> is identifiable from G.</blockquote><p>In subsections 2.3 and 2.4 we shall describe graphical and symbolic tools to answer these questions.</p><p><strong><em>Interpreting Randomized Control Trials with the do Operator</em></strong></p><p>Lets quickly make contact between the definition (7) of the do operator and the <strong>Randomized Control Trial</strong> (RCT) procedure. Consider a situation where we would like to assess the effectiveness of a treatment on a group of patients. Say that <em>X</em>=1 means we apply the treatment and <em>X</em>=0 we don’t and that <em>Y</em> represents the resulting impact of their health (“improved”’, “stable”, “deteriorated”). Patients are characterized by features like <em>Z</em>_1=age, <em>Z</em>_2=gender and <em>Z</em>_3=is diabetic which could also influence their health state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSN3gFeetWaIzfkzJxY6SA.png" /><figcaption><strong>Figure 6 </strong>: (a) The causal diagram of the combined impact of the treatment X and the features <strong>Z</strong>=(Z_1 = age, Z_2 = gender, Z_3 = ``is diabetic’’) of a patient on his health Y, (b) the causal diagram when the experimenter chooses himself the patients to whom he administers the treatment, thus potentially transforming <strong>Z</strong> into confounders, (c) the treatment is administered by randomly flipping a coin C thus decoupling the treatment from any potential confounders.</figcaption></figure><p>The corresponding causal diagram is shown in figure 6 (a). For this diagram we would like to compute <em>p</em>(<em>y</em>|do(<strong>x</strong>)). If the experimenter chooses which patient she will administer the treatment to, she could inadvertently transform the features <strong>Z</strong> into confounders that will simultaneously impact the decision <em>X</em> to administer the treatment and the health <em>Y</em> of the patient. This is represented in figure 6 (b). The RCT procedure subordinates the decision to administer the treatment to the result of flipping a perfect coin <em>C</em> whose outcome is neither influenced by <strong>Z</strong> nor has any direct influence on <em>Y</em>. It thus cuts the same incoming links to the instrumented variable <em>X</em> as those which had to be removed to define <em>p</em>(<em>y</em>|do(<em>x</em>)) in (7). In such a circumstance <em>p</em>(<em>y</em>|<em>x</em>,<em>c</em>)=<em>p</em>(<em>y</em>|<em>x</em>), because <em>X</em> blocks the path between <em>C</em> and <em>Y</em>. Therefore (9) implies that <em>p</em>(<em>y</em>|do(<em>x</em>))=<em>p</em>(<em>y</em>|<em>x</em>). In other words, when using the RCT procedure observing <em>X</em> has the same effect on predicting <em>Y</em> as prescribing the value of <em>X</em>.</p><p><strong><em>Can we Infer a Causal Graph from Raw Data?</em></strong></p><p>In sections 2.3 and 2.4 we shall describe tools to answer the identifiability question above assuming that we are given a causal graph <em>G</em> and that some of its variables <strong>Z</strong> can be measured. But what if we have no causal graph <em>G</em> available in the first place? Can we infer it directly from data? This is a secular question which has sparked a lot of controversy. In everyday life we all use some clues to identify a causal relationship, the most important one being the assumption that a cause always precedes its effects. Analyzing these temporal aspects of causality would however quickly drive us into discussing the origin of the asymmetry between the past and the future and other foundational issues in physics [8]. As interesting as they are, we will not address these issues here, because this would take us too far away from our subject of analyzing the patterns of data which can identity functional causal relations as defined by structural equations (6). We refer to [1] for a broader panorama of causality.</p><p>The common wisdom among statisticians has long been that this identifying a causal model from data is plain impossible. And, indeed, in general, it is impossible as we shall confirm. The interesting point though is that contrary to this common belief there are practically relevant situations where this identification of <em>G</em> <em>is</em> possible, at least in part. Again, a thorough discussion of these matters would be out of the scope for this short paper. We, therefore, limit ourselves to summarizing one significant result in [2] which shows that, assuming a specific interpretation of Occam’s razor, an equivalence class of causal graphs <em>G</em> can be inferred when all variables <strong>X</strong> in <em>G</em> are measurable.</p><p>So let&#39;s assume that the variables <strong>X</strong> are all measurable and that their probability distribution is <em>p</em>(<strong>x</strong>). With no further assumptions, there could exist many different causal graphs compatible with <em>p</em>. Therefore we need to put further restrictions on the causal models we are trying to infer. We shall indeed put two such restrictions. The first, <strong>minimality</strong>, conforms with standard scientific practice and restricts our search to the simplest possible causal graphs <em>G</em> only, the second, <strong>stability</strong>, will be a condition on the causal model <em>M</em> itself. To formulate them precisely we assume that the causal model <em>M</em> defined by (6), depends on <strong>parameters</strong> <strong>θ</strong> that define both the deterministic dependencies <em>f_j</em> and the distributions of the noise variables ϵ_<em>j</em>. Such a parameterized causal model <em>M</em> therefore really defines a set of distributions <em>p</em> that could be obtained by varying the parameters <strong>θ</strong> of <em>M</em>.</p><ul><li>Given two causal graphs <em>G</em>_1 and <em>G</em>_2 consider the parameterized models <em>M</em>_1 and <em>M</em>_2 that are associated with these graphs. Whenever the set of distributions generated by <em>M</em>_2 contains those generated by <em>M</em>_1 we say that the causal graph <em>G</em>_1 is <strong>preferable</strong> to <em>G</em>_2. In other words, the set of distributions compatible with <em>G</em>_1 is smaller than the set compatible with <em>G</em>_2. A causal graph <em>G</em> is said to be <strong>minimal</strong> among a set of graphs when no other graph in that set is preferable to <em>G</em>.</li><li>Given a distribution <em>p</em> generated by a causal model <em>M</em> with fixed parameters values <strong>θ</strong> we should make sure that <em>p</em> has no accidental independence relationships that would hold only for those specific set of parameters values. Changing the value of <strong>θ</strong> to another set of values <strong>θ</strong>’ should not destroy any independence relationship <em>X</em> ‘is independent of’ <em>Y</em>|<em>Z</em> which hold for <em>p</em>. When this holds we say that the causal model generates a <strong>stable</strong> distribution [2].</li></ul><p>Theorem 1 on observational equivalence then implies the following:</p><p><strong>Theorem 3</strong>: If a causal model <em>M</em> generates a stable distribution <em>p</em> then, up to observational equivalence, there is a unique minimal causal graph <em>G</em> compatible with <em>p.</em></p><p>A class of observationally equivalent graphs can be represented graphically by a representation called a <strong>pattern</strong> [2]. A pattern is a partially directed DAG where some edges are directed while others are not. The directed ones correspond to edges that are common to all members of the pattern, while the undirected one could be oriented in either direction. Pearl and Verma [6] developed an algorithm, the <strong>IC algorithm</strong> (for Inferred Causality) which constructs the pattern associated to any stable distribution <em>p</em> on a set of observable variables. We refer to [2] for a detailed description of the IC algorithm and for various extensions of IC to causal models with latent variables. Other interesting results obtained by Pearl pertain to the falsifiability of some assumptions in a causal graph [12,13].</p><h4>2.3 Answering Causality Questions with Graphs</h4><p>As we have seen earlier, the causal effect <em>p</em>(<em>y</em>|do(x) is identifiable as soon as the parents PA(<em>X</em>) of the cause <em>X</em> are measurable. Formula (9) answers the question by showing how we should adjust the conditionals <em>p</em>(<em>y</em>|<em>x</em>, pa) according to the prior probabilities <em>p</em>(pa) of the direct causes. In this subsection we describe two simple graphical criteria which answer the question in more general cases.</p><p><strong><em>The Back-Door Criterion</em></strong></p><p>The following holds [2,3]:</p><p><strong>Theorem 4</strong>: <em>The effect p</em>(<em>y|do</em>(<em>x</em>))<em> on Y of an intervention on X is identifiable from the causal graph G when a group </em><strong><em>Z</em></strong><em> of observable r.v. satisfy the following two conditions:</em></p><ul><li><em>No variable Z_i is a descendant of X in G. In other words, X should have no influence on any of the variables in </em><strong><em>Z</em></strong><em>.</em></li><li><em>The group of variables </em><strong><em>Z</em></strong><em> should block any path γ between X and Y in G that has an incoming arrow into X (back-door paths).</em></li></ul><p><em>When both conditions are verified we have the reduction:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*RFs47QLSbjg5pj8u9CJ3vQ.png" /></figure><p>The above reduction formula can be considered as a generalization of the basic adjustment formula (9). Both conditions in theorem 4 can be easily tested systematically. Various sets <strong>Z</strong> can be tried to optimize the cost of their measurement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*904_vtmR7XatZFqYQqt3ww.png" /><figcaption><strong>Figure 7</strong> : An example of a group of r.v. <strong>Z</strong>=(Z_3,Z_4) that make the intervention of X on Y identifiable. Indeed Z_3 is a measured chain that blocks γ_1 and γ_2 while Z_4 blocks γ_3 as a measured chain and γ_4 as a measured fork. On the other hand <strong>Z</strong>’=(Z_4) does not because the path γ_2 remains unblocked by Z_4 which is a measured collider.</figcaption></figure><p>Figure 7 gives an example of a group <strong>Z</strong>=(<em>Z</em>_3,<em>Z</em>_4) which makes the causal influence of <em>X</em> on <em>Y</em> identifiable while <strong>Z</strong>’=(<em>Z</em>_4) does not.</p><p><strong><em>The Front-Door Criterion</em></strong></p><p>Condition 1 in theorem 4 requires that the cause <em>X</em> should not affect the observable variables <strong>Z</strong>. Fortunately, another criterion, namely the Front-Door criterion allows us to prove that the effect of <em>X</em> on <em>Y</em> is nevertheless identifiable in other some cases. Consider the situation depicted in figure 8 obtained by amalgamating <em>Z</em>_1 to <em>Z</em>_5 in figure 7 into a group <strong>U</strong> which we assume to be unobserved then renaming <em>Z</em>_6 as Z and denoting <strong>Z</strong>=(<em>Z</em>). This variable <em>Z</em> is under direct influence of <em>X</em> and does not block the path <em>X </em>← <strong>U</strong> → <em>Y</em>. Therefore <strong>Z</strong> meet neither of the two back-door criteria.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*8A5ujVEGqlotgPyOOgKgFQ.png" /><figcaption><strong>Figure 8 </strong>: A causal graph which satisfies the conditions for applying the front-door criterion.</figcaption></figure><p>Note that the following three conditions hold in the example of figure 8:</p><ul><li>The variables <strong>Z</strong> block the directed path from <em>X</em> to <em>Y</em>.</li><li>All back-door paths from <em>X</em> to <strong>Z</strong> are blocked. Indeed in the example the path <em>X </em>← <strong>U</strong> → <em>Y</em> ← <strong>Z</strong> is blocked at <em>Y</em> which is an unconditioned collider.</li><li>All back-door paths from <strong>Z</strong> to <em>Y</em> are blocked by <em>X</em>. Indeed in the example the path <strong>Z </strong>← <em>X</em> ← <strong>U</strong> → <em>Y</em> is blocked by <em>X</em> which is a conditioned chain.</li></ul><p>When these three conditions are met we say that the variables <strong>Z</strong> satisfie the <strong>frond-door criterion</strong> relative to the causal effect of <em>X</em> on <em>Y</em>. The following then holds:</p><p><strong>Theorem 5</strong>: <em>When the variables </em><strong>Z</strong><em> satisfy the front-door criterion for the effect of a variable X on a variable Y, then this effect is identifiable and is given by</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*ALbKHeT4CFjICnzCUyaeaQ.png" /></figure><p>Notice that the variables <strong>u</strong> do not appear in the above reduction formula as should be the case for unmeasured variables. This second graphical tool thus complements our arsenal for discovering identifiable causal graphs. We will prove it in subsection 2.4 as an example application of the do Calculus.</p><h4>2.4 Answering Causality Questions with the Do-Calculus</h4><p>Graphical tools are nice because they allow us to identify causal relationships without having to do any math. Unfortunately, this is not always possible. In this subsection we present three simple algebraic rules [3] that can be combined to transform expressions containing both ordinary conditioning .|<strong>x</strong> and interventions .|do(<strong>x</strong>) into equivalent expressions. These rules are the rule of the <strong>do Calculus</strong>. Our goal, of course, is to find an appropriate sequence of these transformations to eventually get rid of all .|do(<strong>x</strong>) in order to prove that an intervention is identifiable.</p><p>Assume we are given four disjoint subsets of variables <strong>X</strong>, <strong>Y</strong>, <strong>Z</strong> and <strong>W</strong> in a causal graph <em>G</em>. Let us denote by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/1*2o4a8GHB8k6x9tT3f5hnJg.png" /></figure><p>the graphs obtained from <em>G</em> by respectively deleting the links incoming into <strong>X</strong> and outgoing from <strong>X</strong>. To represent simultaneous removal of incoming and outgoing links we use a notation like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/44/1*rBVcTjNDCxu3w7i-biuDUQ.png" /></figure><p>At last, <em>Z</em>(<strong>W</strong>) will denote the set of <em>Z</em>-nodes which are not ancestors of any <em>W</em>-nodes in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/41/1*OdYt0T_3nUKg8mTohW7D7g.png" /></figure><p>In the 3 rules below, <strong>X</strong> always enters as a do(<strong>X</strong>) intervention, while <strong>W</strong> occurs as a passive observation and <strong>Y</strong> as the consequences we would like to predict. We also define a mixed conditional probability on <strong>Y</strong> given an intervention on <strong>X</strong> and an observation of <strong>W</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*La12tR5Kn3IWegpR4w6Biw.png" /></figure><p><strong>Theorem 6 </strong>(do Calculus Rules): <em>Assume that the distribution p is generated by a causal model associated with the graph G. Then the following holds:</em></p><ul><li><strong>Rule 1</strong> [<em>removing an observation</em>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*o43_ZjWNYQ67SiYLyewGuA.png" /></figure><ul><li><strong>Rule 2</strong> [<em>removing an intervention</em>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*H6DnFy5c3w4LqP22T9kETw.png" /></figure><ul><li><strong>Rule 3</strong> [<em>replacing an intervention with an observation</em>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*iYZtQMWNX68hOxIQ1cXc7A.png" /></figure><p>These rules generalize the basic <em>d</em>-separation rule (5) which recall here for comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*F1JOnan8zWwcK3301pK0jw.png" /></figure><p>In fact (13) is a special case of rule 1 when <strong>X </strong>is empty. <br>In the other way around, we can easily understand rule 1 as a consequence of (13) when we remember that an intervention do(<strong>x</strong>) simply removes from <em>G</em> all links entering into <em>X</em>. What results is precisely the graph used in rule 1. Rules 2 and 3 use sub-graphs of that graph. Rule 3 answers the important question of whether an intervention on the variable <em>Z</em> has the same effect as its passive observation. The simplest case where rule 3 applies is when <em>G</em> is the two-node graph <strong>Z</strong> → <strong>Y</strong>, describing a direct causal effect, for which</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/34/1*Mjf3IS_9zBDuT8mcX437oQ.png" /></figure><p>reduces to two disconnected nodes thus trivially ensuring that <strong>Z</strong> and <strong>Y </strong>are <em>d</em>-separated with that graph.</p><p><strong><em>An Example — Deriving the Front-Door formula</em></strong></p><p>As an example of an application of the do Calculus let’s see how we can use them to derive the front door rule (11), referring to figure 9 for the various subgraphs that we shall need to examine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ojg3KUO4nx8YKMlymJFhnQ.png" /><figcaption><strong>Figure 9</strong> : The original graph G considered in the front-door rule and the subgraphs used for its derivation.</figcaption></figure><p>Lets go through this step by step following [3].</p><p>First, using the sum rule and definition (12), the desired quantity can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*0B4A_4r1QZDKb6fosLzcww.png" /></figure><p>Now we can apply rule 3 to remove the do operator on <strong>x</strong> in the second factor of (14) to write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*JcPK5kVCfRihPrbgL1MtrA.png" /></figure><p>Lets now focus on the factor <em>p</em>(<strong>y</strong>|<strong>z</strong>, do(<strong>x</strong>)) in (14). Using rule 3 again we can replace <strong>z</strong> by do(<strong>z</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*B4lEns1B0X8b5ZSRBWy4GA.png" /></figure><p>Rule 2 now allows deleting the do(<strong>x</strong>) action from the right member of (16), therefore</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*6D8rhN7Yir6N-G88nB1SWA.png" /></figure><p>Lets thus compute <em>p</em>(<strong>y</strong>|do(<strong>z</strong>)). Apply definition (12) on mixed conditioning and marginalizing over <strong>x</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*bF9qSNktMWe0M_6zR9O6Bw.png" /></figure><p>We can apply rule 2 which implies <em>p</em>(<strong>x</strong>|do(<strong>z</strong>))=<em>p</em>(<strong>x</strong>). We can also apply rule 3 which implies <em>p</em>(<strong>y</strong>|<strong>x</strong>, do(<strong>z</strong>))=<em>p</em>(<strong>y</strong>|<strong>x</strong>, <strong>z</strong>). Altogether (18) and these last two results imply</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*Scw7TdWmH0elTF_qfiKr6w.png" /></figure><p>Combining (16), (17) and (19), we get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*ciHgVkvliik6aWkj6c6p-Q.png" /></figure><p>Eventually, combining (14), (15) and (20), we get the desired result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*KBAszzZj46UiWEmvpozKcw.png" /></figure><p>which is the same as the front door rule (11).</p><p>As this example shows, the do Calculus allows for elegant derivations of identifiability cases but by no means is it obvious! On the contrary, it requires a fair amount of intuition and practice.</p><p><strong><em>Strengths and Limitations of the Do Calculus</em></strong></p><p>The rules of the do Calculus have been shown to be <strong>complete</strong> [10] in the sense that, if an intervention is identifiable at all, then there exists indeed a sequence of these 3 rules that will produce an expression free of any do operator. Unfortunately, there is <strong>no general rule</strong> for deciding whether an expression is identifiable or not [2]. In fact one the main difficulty in applying the do Calculus is that there is no general guiding principle that tells us which rule to apply at each step. Luckily, courageous people have been compiling both identifiable and non identifiable causal diagrams that we can reuse. Figure 10 shows examples which are identifiable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_UjlQsuuXa-cblKVgDVO7Q.png" /><figcaption><strong>Figure 10</strong> : Examples of simple causal graphs where the effect of X on Y is identifiable. All graphs are maximal.</figcaption></figure><p>One important remark is that we can generate many more identifiable diagrams from these as soon as we realize the following two facts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJ2KQ4sfGa3CTkluBkimxA.png" /><figcaption><strong>Figure 11</strong> : Examples of simple causal graphs where the effect of X on Y is not identifiable.</figcaption></figure><ul><li><strong>Adding an edge</strong> to any causal diagram <em>G</em> can only decrease the chances that the new graph will be identifiable. This is a direct consequence of the fact that all rules we have been discussing, whether graphical or algebraic, ultimately amount to testing whether some paths within subsets of <em>G</em> are blocked. Adding an edge obviously increases the number of paths to test and thus decreases the chances that they will all be blocked.</li><li><strong>Adding an observed variable</strong> on an edge of a graph has the opposite effect. It can only increase the chances that the new graph will be identifiable because it adds an observed chain which is an additional blocking point that can only enhance the chances of <em>d</em>-separation between groups or variables.</li></ul><p>All diagrams shown in figure 10 are <strong>maximal</strong> in the sense that adding a single edge to any of them will destroy their identifiability. They are thus the most useful graphs to list. Figure 11 shows examples which are not identifiable.</p><h3>3. Causal Analysis of Simple Business Examples</h3><p>Examples of causal analysis are often drawn from fields like agronomy, social sciences or economics which rely on complex causal models. We rather chose to illustrate how causal analysis naturally occurs in even the most common business examples.</p><h4>3.1 Assessing the Effectiveness of a Loyalty Campaign</h4><p>The level of satisfaction of customers with a service can often be judged from their observable behavior such as the number of visits to a website or the time spent for using that service. This information can help the service provider to identify early signs that some customers intend to leave the service. Marketing can then decide to launch a loyalty campaign that aims at retaining the customers whose faith wavers. These campaigns of course have a cost and its therefore important to be able to assess their effectiveness. Does a loyalty campaign of a certain type really have an impact on the attrition rate?</p><p>To answer this question let’s formalize the problem. First, let <em>U</em> be a binary variable that corresponds to the intention of the customer to leave the service or not, before being targeted by any loyalty campaign. This, of course, will be an unmeasured variable. This initial intention <em>U</em> certainly has an impact on the behavior of the customer that can be measured, let’s call this <em>Z</em>. This behavior <em>Z</em> will determine in turn the decision by the service provider whether this customer should be targeted by a loyalty campaign. Let’s call this decision <em>X</em>. Eventually, the final decision of the customer to cancel the service is again a binary variable, call it <em>Y</em>. This final decision of the customer is certainly dependent both on his initial intention <em>U</em> and whether he has been targeted or not by the campaign (<em>X</em>). So, formally, our question translates as : can we identify the causal impact of being target <em>X</em> on the final decision <em>Y</em> when we measure <em>Z</em> ? Figure 12 shows the corresponding causal diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*dSK4vJ5eSdZG2UPamAstuA.png" /><figcaption><strong>Figure 12</strong> : The causal model of the impact of a loyalty campaign on the churn rate.</figcaption></figure><p>This diagram is nothing but the diagram (c) from the list of identifiable diagrams in figure 10 with the direct link from <em>Z</em> to <em>Y</em> removed. Therefore it is identifiable. On the other hand <em>Z</em> satisfies the two condition of the back-door criterion in theorem 4. It is not a descendant of <em>X</em> and it blocks the back-door path between <em>X</em> and <em>Y</em> because it is an observed chain. Thus (10) gives the explicit reduction of the causal impact of <em>X</em> on <em>Y</em> into observable quantities.</p><h4>3.2 Claim Provisioning by an Insurance Company</h4><p>When a claim is reported by an insured, an insurer usually sets aside a certain amount. This is especially true when personal injury is reported. The final compensation will obviously depend on the extent of the damage. But, as insurers have become aware, this compensation will also depend on the initial provisioning. The aim of causal analysis here is to determine the impact of this provisioning on the final compensation granted to the insured.</p><p>Let <em>U</em> be the complete claim characterization. Its value is unknown at the time of reporting but it will determine both the declaration <em>Z</em> by the insured and the final compensation <em>Y</em> granted after investigations. The initial evaluation <em>Z</em> is what directly determines the expert’s provisioning <em>X</em> which in turns impacts the final compensation <em>Y</em>. The causal graph is thus exactly the same as in figure 12 and, as a consequence, the same back-door reduction formula (10) applies here as well.</p><h4>3.3 Impact of Sales Force Training on Turnover</h4><p>To improve the efficiency of its sales teams, a company can invest in their training. This has an easily measurable cost <em>X</em> which it is hoped will help to increase the turnover <em>Y</em> by increasing sales. As such, the causal relationship would be direct and thus trivially identifiable. However there is at least one unmeasured confounding variable which spoils this identifiability, namely the competitive pressure <em>U</em>. Indeed a strong competitive pressure <em>U</em> will encourage investment <em>X</em> in a training effort but, simultaneously, it will also impact the turnover <em>Y</em>. Fortunately though, we can restore identifiability if we can find a measurable “deconfounding” variable <em>Z</em> within the causal chain from <em>X</em> to <em>Y</em>. The skills and motivation of salespeople induced by these training and measured by surveys or polls could play this role. The causal graph is depicted in figure 13, it is the same as in figure 8 which was the basic graph for which the front-door rule applies. We can thus use the front-door reduction formula (11).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*HbbFHW1Unv1tiq1JB6IgXA.png" /><figcaption><strong>Figure 13</strong> : Causal graph for the impact of a training investment on the turnover leveraging an evaluation of the skills and motivation of salespeople.</figcaption></figure><h4>3.4 Impact of Pricing on Sales</h4><p>The turnover <em>Y</em> for a company on a product is a function of the price <em>X</em> of the item and its sales volume <em>Z</em>. For instance <em>Y</em> could be proportional to <em>X</em> * <em>Z</em>. Now the price <em>X</em> impacts both the turnover <em>Y</em> but also the sales volume <em>Z</em>, because lower prices generally increasing the volume. As such, the corresponding causal graph would be identifiable because it corresponds to graph (b) from in the list of identifiable graphs from figure 10 with the confounding link between <em>Y</em> and <em>Z</em> removed. Unfortunately, the competition pressure <em>U</em> which is an unknown variables is a confounder which impacts both the price <em>X</em> and the sales volume <em>Z</em> rendering the graph in figure 14 unidentifiable as it is the same as the graph (c) in the list of unidentifiable graphs in figure 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*BIFmxPRzK7jlRKMEKodkpA.png" /><figcaption><strong>Figure 14</strong> : The impact of pricing on turnover is unidentifiable because of the competition pressure.</figcaption></figure><h3>4. Stuff Worth Knowing for Data Scientists?</h3><p>Once one fully grasps the importance of the paradigm shift implied by the Causal Revolution, a question will occur to many newcomers. Why hasn’t anyone ever told me about this while I as learning statistics, probability or machine learning? How come as a data scientist I’ve never heard of the do Calculus? Is it really useful in practice? In what area? There are probably several answers to this. We list some of them below.</p><ul><li>The first reason we see is of cultural nature. This has been well analyzed in [5] for instance. In reality the word “causality” has long remained almost taboo in the statistical community which remained faithful to the classical associationist point of view of the founders of the discipline in the last century like Pearson and Fisher. They considered that there can be no evidence about causation within data (except for RCT). It took all the perseverance and scientific stature of Judea Pearl to reverse people’s minds on the relationship between causality and statistics. Apparently, this paradigm shift has yet to infuse the newer data science community at large.</li><li>The graphical and algebraic machinery we presented in section 2 obviously only makes sense when the causal graph <em>G</em> is non trivial. This explains why fields like social sciences, economics, medicine or agronomy, which have all developed a rich set of causal models, have benefited most from this renewed perspective on causality. For an elementary causal relationship like <em>G </em>= <em>X</em> → <em>Y</em> there is however no difference between the passive observation of the cause <em>X</em> and an intervention on it. Many use cases worked out by data scientist fall into this category, perhaps in some cases just by chance. But without such luck, neglecting the difference between observation and intervention could lead to predictions errors. We presented a number of examples of such cases in section 3.</li><li>While the graphical rules are rather accessible, the judicious application of the do Calculus to new causal diagrams undoubtedly requires skill and intuition. As was suggested in [5], the do Calculus could certainly benefit from a cookbook for those who cannot afford or don’t want to master this kind of algebraic machinery.</li><li>One last reason, a more subjective one, has to do with Pearl’s writing style [2] which, at times lacks perhaps a bit of conciseness. This can certainly discourage many readers, even those who have all prerequisites in statistics and probability theory. The sheer number of historical anecdotes, examples and comments that Pearl gratifies his readers with sometimes runs counter to a clear presentation of the key mathematical facts. The Causality Revolution probably still lacks a concise textbook-like presentation of the subject.</li></ul><p>The founding fathers of statistics were certainly right when they insisted that, in general, we cannot infer causal relations from mere data. But in the enthusiasm of their nascent discipline, many of their disciples and epigones have somehow become overzealous. They neglected that in most cases we have more information available than just data! We have some prior knowledge of how the world works! Perhaps not a full-fledged causal model, but at least a partial causal graph. What Pearl tells us is that in some favorable conditions (that we discussed in section 2), we can merge those two pieces of knowledge in order to predict the effect of an intervention on a system. If it turns out that these predictions do not match observations, we just have to work harder and think of some better model. But, in any case, we have to give up the hope of automating the discovery of how the world works from observation only. Nature won’t reveal its charms in front of some dumb algorithm. She is a demanding mistress and expects us to engage in a thoughtful conversation with her, as curious and creative minds. So, let’s rejoice, because this is why science is so much fun!</p><h3>References</h3><ol><li>J. Pearl, D. Mackenzie (2018), <em>The Book of Why</em>, Basic Books.</li><li>J. Pearl (2009), <em>Causality</em>, Cambridge University Press.</li><li>J. Pearl (1995), <em>Causal diagrams for empirical research</em>, Biometrika (1995), 82,4, pp. 669–710.</li><li>D.R. Cox (1958) <em>The Planning of Experiments</em>, John Wiley and Sons, NY.</li><li>S. Powell (2018), <em>The Book of Why: The New Science of Cause and Effect</em>, Journal of MultiDisciplinary Evaluation<br>Volume 14, Issue 31, 2018.</li><li>J. Pearl and T. Verma (1990), <em>Equivalence and synthesis of causal models</em>, Proceedings of the Sixth Conference on Uncertainty in Artificial Intelligence, pp 220–227.</li><li>J. Pearl and T. Verma (1991), <em>A theory of inferred causation</em> in Principles of Knowledge Representation and Reasoning: Proceedings of the Second International Conference, pages 441–452. Morgan Kaufmann, San Mateo, CA.</li><li>H. Reichenbach (1956), <em>The Direction of Time</em>, University of California Press, Berkeley.</li><li>Ch. M. Bishop (2016), <em>Pattern Recognition and Machine Learning</em>, Springer-Verlag New York Inc.</li><li>Y. Huang, M. Valtorta (2006), <em>Pearl’s Calculus of Intervention Is Complete</em>, UAI-06: Proceedings of the Twenty-Second Conference on Uncertainty in Artificial Intelligence, pp. 217–224.</li><li>D. Galles and J. Pearl (1995), <em>Testing identifiability of causal effects</em>, UAI-95: Proceedings of the Eleventh Conference on Uncertainty in Artificial Intelligence, pp. 185–195.</li><li>J. Pearl (1994), <em>From Bayesian networks to causal networks</em>. In Bayesian Networks and Probabilistic, edition A. Gammerman, pp. 1–31. London: Alfred Walter.<br>Reasoning</li><li>J. Pearl (1995), <em>Causal inference from indirect experiments</em>. Artif. Intel. Med. J. 7, pp 561–582.</li></ol><p><a href="https://arxiv.org/abs/2007.03940">PDF version with LaTeX typesetting on arXiv</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dfa4ce1b465" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/reconciling-causality-and-statistics-1dfa4ce1b465">Reconciling Causality and Statistics</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>