Implementing Causal Impact on Top of TensorFlow Probability | by Will Fuks | Dec, 2020


Using structural time series to infer impactful causality between variables.

Will Fuks

One day a good friend and coworker of mine came to me and asked a question that would “haunt me” to this day. In fact, this post, written years after that question, is a derivation of that conversation.

He asked:

-Hey man! We are trying to solve an interesting problem, maybe you can help us out! The challenge is, we want to run a marketing campaign on national television and we want a way to analyze the real impact that it had on our sales. How can we do that in a reliable way?

To which I promptly answered: “man…without a control group I have no idea…😕”.

Well, as we came to learn later on, there’s actually a set of techniques developed to solve this exact type of problem, also known as Causal Impact inference which will be addressed in this post.

With my coworker question in mind, here’s what we’ll be covering in this article:

  • Brief discussion about causality.
  • Bayesian structural time series (bsts).
  • Introduction to tfcausalimpact built on top of Python.
  • Examples.

We’ll be able to fully analyze whether a given random variable causes impact on another one (given a degree of confidence) which will allow us to solve a huge amount of recurring problems in the data science field.

The concept of causality is probably one of the most powerful in the field of data science as well as it’s probably one of the most difficult and complex to understand and implement.

Deriving causality is what could bring us new drugs to fight diseases, a deeper understanding of the human brain, better explanations to various observed phenomena and so on.

In fact, it’s by understanding causality that I could have helped my coworker on the television advertisement challenge: once we find the causal relationship between marketing investment on TV networks and sales revenue we can infer how both are expected to behave, even when manipulating one of them (by increasing investments in marketing for instance).

Using a Bayesian perspective, here’s a simple depiction of a causality relationship between two random variables X and Y:

Read More …


Write a comment