<?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 Rama Ramakrishnan on Medium]]></title>
        <description><![CDATA[Stories by Rama Ramakrishnan on Medium]]></description>
        <link>https://medium.com/@rama100?source=rss-28748480e8bd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GwaR72ZyKK1EN5UbJTayTA.jpeg</url>
            <title>Stories by Rama Ramakrishnan on Medium</title>
            <link>https://medium.com/@rama100?source=rss-28748480e8bd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:39:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rama100/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[How ChatGPT can answer complex questions and execute actions by using external tools (a…]]></title>
            <link>https://medium.com/@rama100/how-chatgpt-can-answer-complex-questions-and-execute-actions-by-using-external-tools-a-c0f92b12306d?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f92b12306d</guid>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 12:06:07 GMT</pubDate>
            <atom:updated>2023-06-16T12:06:07.826Z</atom:updated>
            <content:encoded><![CDATA[<h3>How ChatGPT can answer complex questions and execute actions by using external tools (a non-technical explainer)</h3><figure><a href="https://www.linkedin.com/posts/ramar_how-chatgpt-can-use-external-tools-activity-7074797227524673536-aJfX"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VFIrgO2rj6LfSRGLAWafPg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f92b12306d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How ChatGPT was built]]></title>
            <link>https://medium.com/@rama100/how-chatgpt-was-built-6363fc392bcd?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6363fc392bcd</guid>
            <category><![CDATA[gpt-3]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 13:28:01 GMT</pubDate>
            <atom:updated>2023-03-09T13:28:01.862Z</atom:updated>
            <content:encoded><![CDATA[<figure><a href="https://www.linkedin.com/posts/ramar_the-road-to-chatgpt-an-informal-explainer-activity-7038334518004482048-h3G5?utm_source=share&amp;utm_medium=member_desktop"><img alt="" src="https://cdn-images-1.medium.com/max/549/1*ANs15D1gYTJUpIAKvhXZdQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6363fc392bcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Big Should Your Sample Size Be?]]></title>
            <link>https://medium.com/data-science/how-big-should-your-sample-size-be-54ab2154c152?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/54ab2154c152</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[sampling]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 08:12:07 GMT</pubDate>
            <atom:updated>2022-12-15T08:12:07.662Z</atom:updated>
            <content:encoded><![CDATA[<h4>A handy little formula that every data scientist should know</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*waM6iszfUlrH4M4c" /><figcaption>Photo by <a href="https://unsplash.com/@artturijalli?utm_source=medium&amp;utm_medium=referral">Artturi Jalli</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You are in a meeting with the CEO and the executive team.</p><p>The Product team is pitching a new product idea. It has lots of cool features and will work smoothly with the company’s current products. They think existing customers will love it. They think it is a great way to increase share of wallet from the customer base. They are asking the CEO for budget to build the product.</p><p>The Sales team isn’t so sure. They think there’s no burning reason for an existing customer to buy the new product —they think it is a vitamin, not a painkiller. They think most customers won’t buy. They think it will be a waste of money to build it.</p><p>They all look to the CEO but she is not ready to decide. She is very data-savvy. She wants to survey a <em>random</em> <em>sample</em> of existing customers and see what % of them want to buy the new product*.</p><p>She turns to you. <em>Can you run the numbers and let me know by end of day how many customers we should survey? I want the margin of error to be plus-minus 3 percentage points.</em></p><p>You reply at lightning speed: <em>About 1100 customers</em>.</p><p>She is dazzled by the speed of your response. <em>Wow, that was fast.</em></p><p>You try to look modest :-).</p><p>She continues. <em>Surveying 1100 customers will be too expensive. Let’s say that I am OK with a margin of error of plus-minus 5 percentage points. How many customers then?</em></p><p>Another instant response from you: <em>400 customers</em>.</p><p><em>That’s better.</em> She turns to the Marketing team. <em>Let’s do a random survey of 400 customers and meet again when the results are in.</em></p><p>The CEO leaves. The meeting ends.</p><p>People gather around you. <em>How did you do that?</em></p><p>Simple. This is the handy little formula (<a href="https://en.wikipedia.org/wiki/Sample_size_determination#Estimation_of_a_proportion">source</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*FYN3b6ZivI3RJBJcbswHNg.png" /></figure><p>With this, you can use your phone calculator to rapidly find the approximate sample size for any margin-of-error.</p><p><strong><em>But some margin-of-error numbers — 1%, 3% and 5% — are so common in the business world that you should memorize the results</em></strong>. After all, appearing to do lightning-fast mental math is more impressive than taking out your phone ;-).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*lgxpr-Q4_vx4p4e5P0WzbA.png" /></figure><p>And there’s one more thing. You can flip the formula around too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*1lFlLDylVI5KiVoZTQNCOQ.png" /></figure><p>Now you can handle the ‘reverse’ question: <em>I can only afford to survey 250 customers. What is the margin of error in that case?</em></p><p>No problem. Pull out your phone’s calculator and calculate 1 / (square root of 250) which is 0.063 (i.e., an MOE of plus-minus 6.3).</p><p>Nice, huh?</p><p>That’s it. Go forth and impress! :-)</p><p><strong><em>Where does this formula come from?</em></strong></p><p>Let’s start with an age-old stats question.</p><blockquote><em>How many people should we randomly sample so that we can estimate a population proportion within a margin-of-error of plus-minus MOE with 95% confidence**?</em></blockquote><p>In our example,</p><ul><li>the population = all existing customers</li><li>population proportion = % of all existing customers who want to buy the new product</li><li>MOE = recall that the CEO asked for 3% margin-of-error first and later 5%</li></ul><p>The age-old question above has an age-old <a href="https://en.wikipedia.org/wiki/Sample_size_determination#Estimation_of_a_proportion">answer</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*PGXmf7UFzPm6D9LfEwEXQQ.png" /></figure><p><em>p</em> is the <em>sample proportion</em> — the % of people <strong>surveyed</strong> who say they will buy the product.</p><p>But we haven’t done the survey yet so we don’t know <em>p (</em>in fact, the whole point here is to figure out <em>p</em>, right?). So what will we plug into the formula for <em>p</em>?</p><p>A little math comes to our rescue.</p><p>Turns out, for <em>p </em>between 0 and 1<em>, </em>this is always true:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*UcFEI64hT8oXjIVwEtm27A.png" /></figure><p>(you can plot it and confirm for yourself or just do a little calculus and prove it)</p><p>Since the sample size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/1*U6z9kORkvXy7aEz_KX4WDA.png" /></figure><p>is <strong>at most</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/90/1*Lcllfu-0Kvw5PsGwnbT-vg.png" /></figure><p>the original formula can be approximated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*Lnprnlm9Fp_6Yh2PpfUi5A.png" /></figure><p>Note that since there is no <em>p</em> in</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Lcllfu-0Kvw5PsGwnbT-vg.png" /></figure><p>we have solved the “I don’t know what to plug in for <em>p</em>” problem.</p><p>Next, notice that 1.96 (0.5) = 0.98 is just slightly less than 1.0. So this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/90/1*Lcllfu-0Kvw5PsGwnbT-vg.png" /></figure><p>can be approximated by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/85/1*c_BWN3UqYTSU-f4pgwIAWg.png" /></figure><p>Putting it all together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*VmWYRTENd5NkkIya9K5YrA.png" /></figure><p>We are done!</p><p><em>Important caveat</em>: Because of the simplifications we are making, this formula is <strong><em>conservative. </em></strong>It will recommend a more-than-needed sample size if the true value of <em>p</em> is far from 0.5.</p><p>If you can guess at the likely value of <em>p</em> from previous similar surveys, you can use that value of <em>p</em> in this formula instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PGXmf7UFzPm6D9LfEwEXQQ.png" /></figure><p>*Yes, she is aware that what people <em>tell</em> you in surveys may not be what they will actually <em>do. </em>Here’s a fun recent example (<a href="https://medium.com/magnetic/52-things-i-learned-in-2022-db5fcd4aea6e">source</a>):</p><blockquote>Researchers asked 100 people whether a reasonable person would unlock their phone and give it to an experimenter to search through. Most said no. Then the researchers asked 103 other people to unlock their phone and give it to them. 100 of them complied.</blockquote><p>**The confidence level doesn’t have to be 95% but it is used for two reasons.</p><ul><li>It is very common in the business world</li><li>Conveniently for us, the associated Z-score of 1.96 nicely multiplies the 0.5 to give us a number close to 1.0, which leads to the super-simple formula for the sample size.</li></ul><p>To use a different confidence level, you will need to replace 1.96 with other values in the formula above. <a href="https://en.wikipedia.org/wiki/Sample_size_determination#Estimation_of_a_proportion">More</a>.</p><p>If you liked this article, you may like these too (I realize I am sounding like a recommendation engine :-)).</p><p><a href="https://medium.com/p/7ddc935ab365">I have data. I need insights. Where do I start?</a></p><p><a href="https://medium.com/p/e66dbf8a8a47">Create a Common-Sense Baseline First</a></p><p><a href="https://medium.com/p/b5efbdbf8ab0">How to Use Causal Inference In Day-to-Day Analytical Work</a></p><p><a href="https://medium.com/p/1e38404dd2d5">Lessons from a Deep Learning Master</a></p><p><a href="https://medium.com/p/1edbfdcb725d">From Prediction to Action — How to Learn Optimal Policies from Data</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54ab2154c152" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-big-should-your-sample-size-be-54ab2154c152">How Big Should Your Sample Size Be?</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[From Prediction to Action — How to Learn Optimal Policies From Data (4/4)]]></title>
            <link>https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/14c63cc0c938</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[uplift-modeling]]></category>
            <category><![CDATA[contextual-bandit]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Thu, 12 Aug 2021 15:00:26 GMT</pubDate>
            <atom:updated>2025-03-26T13:29:33.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Prediction to Action — How to Learn Optimal Policies From Data (4/4)</h3><h4>In this final post of the series, we will learn how to find an optimal policy.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rTt6pdn_VIqjYCsT" /><figcaption>Photo by <a href="https://unsplash.com/@madebyjens?utm_source=medium&amp;utm_medium=referral">Jens Lelie</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recap:</p><ul><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">Part 1</a>, we discussed the need to learn <em>optimal</em> policies from data. Policy optimization covers a <em>vast</em> range of practical situations and we briefly looked at examples from healthcare, churn prevention, target marketing and city government.</li><li>In <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>, we described how to create a dataset so that it is suited for policy optimization.</li><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505">Part 3</a>, we presented a simple way to use such a dataset to estimate the outcome of <strong><em>any</em></strong> policy.</li></ul><p>At the outset, it is worth noting that researchers in many fields — causal inference, econometrics, and contextual bandits — have worked on this problem for many years and have devised numerous algorithms to solve it — doubly-robust methods, direct methods, transformed-outcome methods, double machine learning, the X-Learner, the R-Learner and so on. Take a look at Section 3 of this recent <a href="http://arxiv.org/abs/2007.12769">survey</a> to see what I mean.</p><p>Given this abundance of riches, I was faced with the difficult question of what to focus on in this post. But as luck would have it, one of the research teams that have contributed significantly to this area organized “<a href="http://arxiv.org/abs/1802.04064">A Contextual Bandit Bake-off</a>” in 2018 where many of the key algorithms competed with each other.</p><p>A relatively simple approach called <strong><em>Importance-Weighted Regression</em></strong><em> (IWR) </em>performed admirably in the competition and I describe it below. IWR directly leverages our knowledge of how to build regression models, is intuitive to understand and can be easily implemented using any supervised learning regression approach of your choice (if you are interested in the underlying theory, please see <a href="http://arxiv.org/abs/1803.01088">Practical Contextual Bandits with Regression Oracles</a>).</p><p>In <a href="https://towardsdatascience.com/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>, we assembled a dataset like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RSeDlUQhfoY-I8jFfbiMBQ.png" /><figcaption>Image by Author</figcaption></figure><p>Or, to be more concrete, let’s use the Netflix churn example with 3 actions: offer 20% off, offer free streaming on 2 more devices, do nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-WccbE66OaokAK3QqGuXw.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Our objective is to learn a function from this dataset that assigns the best action to each customer i.e. we want to learn an optimal policy.</strong></p><p>Learning an optimal policy using Importance Weighted Regression (IWR) is a three-step process.</p><p><strong>Step 1</strong>: Split the dataset above based on the <em>actual</em> action that was assigned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Tdzk7h9l1pXWeCf0MHc7Q.png" /><figcaption>Per-Action Dataset (Image by Author)</figcaption></figure><p>You will now have as many datasets as the number of actions.</p><p><strong>Step 2</strong>: With <em>each</em> dataset, build a regression model that predicts the outcome from the customer feature vector <em>x.</em></p><p><strong><em>Crucially, you need to use weighted squared loss as the loss function, where the weights are the reciprocal of the numbers in the probability column.</em></strong></p><p>Regression models typically default to minimizing squared loss so that’s pretty standard. The <em>extra</em> thing you have to do is to send in a weight for each data point in the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*2efx7kLFPXKOY8giyNJ5uQ.png" /><figcaption>Image by Author</figcaption></figure><p>Let’s write this down algebraically so that there’s no ambiguity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*Ba7SH3sUIW4pEqIqpK2qqw.png" /></figure><p>That’s it.</p><p>(BTW, weighted regression is commonly supported out of the box. In <a href="https://scikit-learn.org/stable/index.html">scikit-learn</a>, for instance, <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html">linear regression</a>, <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html">gradient boosting regression</a> and <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html">random forest regression</a> all support weights in a simple and uniform way, using the <em>sample_weight</em> argument of the <strong>fit</strong> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*5OePYO90TJ6fwYRrWVi3Zg.png" /><figcaption>From <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html">https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html</a></figcaption></figure><p>Just set <em>sample_weight </em>to the reciprocal of the numbers in the probability column when you call the <strong>fit</strong> function)</p><p>At the end of this step, you would have built as many regression models as there are actions.</p><p><strong>Step 3</strong>: For any customer feature vector <em>x</em>, run <em>x </em>through<em> </em>each of the models to get the predicted outcome for its action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*TH0dYaMPmlFaPmlQHtuzEA.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Now, pick the action with the highest predicted outcome.</strong></p><p><strong>You have learned an optimal policy!</strong></p><p>As you saw above, the only new thing in IWR (compared to traditional regression) was the use of the reciprocal of the probabilities as weights.</p><p><strong>What’s the intuition behind this use of probabilities?</strong></p><p>For simplicity, imagine that your customer feature vector <em>x</em> had just one element: it is a binary variable that is 1 if the customer in question has ever watched a documentary on Netflix and 0 if they haven’t.</p><p>After consulting with business stakeholders, let’s say you have come up with the following <em>data collection policy</em> (defined in <a href="https://towardsdatascience.com/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgHuLBFLceYnwb0sjURMBQ.png" /><figcaption>Data Collection Policy (Image by Author)</figcaption></figure><p>Let’s focus on the “20% off” column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*66YZ3yfn_bp8ylDcb1AYsw.png" /><figcaption>Image by Author</figcaption></figure><p>Let’s say we choose a random sample of <em>N</em> customers for data collection and documentary watchers represent a fraction <em>p</em> of the sample, so approximately <em>Np</em> customers in our sample will be documentary watchers and <em>N(1-p)</em> customers won’t be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*XyGENqT0Kq8-LSMDe8EgkA.png" /><figcaption>Image by Author</figcaption></figure><p>Given this, the approximate number of customers in the “20% off” dataset will be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*tpbppMbQKTn3GO6WABkLhw.png" /><figcaption>Image by Author</figcaption></figure><p>(i.e., Of the <em>Np</em> customers in our sample who watch documentaries, 50% of those will be assigned “20% off” according to our data collection policy so we get <em>N</em> x <em>p</em> x 0.5)</p><p><em>But we now have a problem. The mix of x =1 and x=0 customers in the “20% off” column is different from the overall mix of x =1 and x=0 customers in the sample. If we build a regression model with this skewed dataset, its prediction of the outcome for a “20% off” action may be biased.</em></p><p>More generally, in a model that you plan to use across your entire customer base, the data points you use to build the model should have <em>x</em> distributed in the same way as across your customer base.</p><p>Returning to our example, how can we fix this issue?</p><p>One approach is to “<em>make copies</em>” of the points in such a way that the mix of x=1 and x=0 points in the “20% off” column matches the overall mix of x =1 and x=0 customers in the sample.</p><p>Let’s say we use a multiplier of <em>u</em> for the x=0 points and <em>v</em> for the x=1 points. After the multiplication (i.e. copying) is done, the new number of points is shown in the rightmost column below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWrOmapBuATI_lm8MAfJug.png" /><figcaption>Image by Author</figcaption></figure><p>How should we choose <em>u</em> and <em>v</em> such that the adjusted number of customers in the “20% off” column match the numbers in the overall sample?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNhIO7LvlgWOSVjQS7Ygdw.png" /><figcaption>Image by Author</figcaption></figure><p>Simple. Just set the multipliers to the <strong>reciprocals of the probabilities!</strong></p><p>Set <em>u</em> = 1/0.5 and <em>v</em> = 1/0.2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_pCWcOsa5heOQij2wLJoJA.png" /><figcaption>Image by Author</figcaption></figure><p><strong>The multipliers and the probabilities cancel out nicely and the adjusted numbers match the overall numbers!</strong></p><p>(In practice, we don’t make copies of the data points. Instead, we simply insert the reciprocals of the probabilities as weights into the loss function and it has the same effect)</p><p>To summarize, using the reciprocal of the probabilities as weights in the regression undoes the skewing of the data points caused by our data collection policy.</p><p>If this reciprocal-of-probabilities business reminded you of how the Horvitz-Thompson Estimator from <a href="http://For the mathematically curious, here’s my attempt at a clearer version of the proof on the Wikipedia page that shows how the Horvitz-Thompson Estimator unbiasedly estimates the outcome of any policy.">Part 3</a> works, your instincts are spot on! In fact, we can use a similar argument to prove that IWR works. If you are curious, an algebraic proof is at the bottom of the post.</p><p>(BTW, this idea of using probability reciprocals to make adjustments is a simple example of a very general and powerful technique called <a href="https://en.wikipedia.org/wiki/Importance_sampling">importance sampling</a> that is widely used in many fields)</p><p>You have learned an optimal policy using IWR, and are ready to put your optimal policy to work.</p><p>I recommend one last tweak before you launch.</p><p>The world keeps changing and the customer behavioral patterns captured and embodied in your optimal policy will change over time. <em>A policy that’s optimal today may not be optimal next quarter</em>.</p><p>Of course, you can periodically gather new data using a data collection policy and learn a new optimal policy with that data. But there’s a better way.</p><p><strong>Add a bit of randomization to your optimal policy and then launch</strong> (see the discussion on <em>epsilon-greedy</em> in <a href="https://towardsdatascience.com/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a> to refresh your memory on how to do this).</p><p><em>By doing so, your optimal policy doubles as a data collection policy. </em>Every so often, you can take the data from this, re-learn an optimal policy using IWR, and switch to that policy (but, again, when you launch it, you will do so with a bit of randomization added).</p><p>In this post, we have described policy optimization as a <strong>batch</strong> cycle: run a data-collection policy for some time, use IWR on the collected data to learn an optimal policy, deploy the optimal policy with a bit of randomization added, and <strong>repeat every so often</strong>.</p><p>But this can be done in <strong>real-time</strong>. In the extreme case, we can do this after <em>every interaction (i.e., after every x -&gt;action-&gt;outcome is observed) </em>by incrementally updating the IWR model corresponding to the action that was assigned. See <a href="https://vowpalwabbit.org/docs/vowpal_wabbit/python/latest/tutorials/python_Contextual_bandits_and_Vowpal_Wabbit.html">here</a> for more.</p><p>Before we conclude, let’s consider a very important special case: <em>when we have just </em><strong><em>two</em></strong><em> actions to choose from</em>. Often, one of these is the <em>active</em> thing (e.g., give medicine X to the patient, offer a discount to the customer) and the other one is the <em>passive</em> thing (e.g., give the placebo, do nothing).</p><p>In Causal Inference/Econometrics in particular, the two-action (or the two-treatment) scenario is extremely common, since oftentimes you want to estimate the effect of an <em>intervention</em> (aka action or treatment) on an existing system, <em>compared to not intervening</em>.</p><p>In this special case, you can actually learn an optimal policy with just <strong>one</strong> model that directly predicts the <strong>difference</strong> in outcomes between the two actions. In some situations, this may be more effective than learning two separate models. To learn more, see section 3 of this recent <a href="http://arxiv.org/abs/2007.12769">survey</a> and follow the references therein.</p><p>In this 4-part series, I have tried to extract the most practical elements of policy optimization from a vast and rapidly growing body of research. There’s tons of really interesting material — here are a few recommendations if you want to learn more.</p><ul><li>IWR was first described only in 2018 (<a href="http://arxiv.org/abs/1803.01088">reference</a>) and if I had tried to write this post before 2018, I would have probably picked the <a href="https://projecteuclid.org/journals/statistical-science/volume-29/issue-4/Doubly-Robust-Policy-Evaluation-and-Optimization/10.1214/14-STS500.full">Doubly-Robust Method</a>. More generally, there are numerous alternatives to IWR and if you are interested, start with this recent <a href="http://arxiv.org/abs/2007.12769">survey</a> and go where your curiosity takes you.</li><li>If you are interested in libraries/modules for policy optimization, here’s a sample: <a href="https://vowpalwabbit.org/index.html">Vowpal Wabbit</a>, <a href="https://causalml.readthedocs.io/en/latest/index.html">CausalML</a>, <a href="https://www.microsoft.com/en-us/research/project/econml/">EconML</a>, <a href="https://www.aboutwayfair.com/data-science/2018/10/pylift-a-fast-python-package-for-uplift-modeling/">PyLift</a>, and <a href="https://cran.r-project.org/web/packages/uplift/uplift.pdf">Uplift</a>. In particular, the <a href="https://vowpalwabbit.org/docs/vowpal_wabbit/python/latest/tutorials/python_Contextual_bandits_and_Vowpal_Wabbit.html">IWR approach described in this post is implemented in the Vowpal Wabbit library</a>.</li><li>If you are interested in a commercially available policy optimization product/service, here’s an <a href="https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/">example</a>.</li></ul><p>Happy learning!</p><p><strong>Optional</strong></p><p>For the curious, here’s an algebraic proof of how IWR works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ab2cr5QzGQx5_3Ilc258w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbafCB2PW0x6chNDP6x_0g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYtEAddzg2IkiXmLmD6NZA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bDEkcsh2CGVeqzkQq-nsvQ.jpeg" /><figcaption>Image by Author</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14c63cc0c938" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">From Prediction to Action — How to Learn Optimal Policies From Data (4/4)</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[From Prediction to Action — How to Learn Optimal Policies From Data (3/4)]]></title>
            <link>https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa56c974a505</guid>
            <category><![CDATA[contextual-bandit]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[uplift-modeling]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 15:25:19 GMT</pubDate>
            <atom:updated>2025-03-26T13:36:12.001Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Prediction to Action — How to Learn Optimal Policies From Data (3/4)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wJ2iBWTeZj5-F426" /><figcaption>Photo by <a href="https://unsplash.com/@burst?utm_source=medium&amp;utm_medium=referral">Burst</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">Part 1</a>, we discussed the need to learn <em>optimal</em> policies from data. Policy optimization covers a <em>vast</em> range of practical situations and we briefly looked at examples from healthcare, churn prevention, target marketing and city government.</p><p>In <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>, we described how to create a dataset so that it is suited for policy optimization.</p><p>In this post, we describe a simple (and, in my opinion, <em>magical</em>) way to use such a dataset to estimate the outcome of <strong><em>any</em></strong> policy.</p><p>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">Part 4</a>, we will learn how to use such a dataset to find an <strong>optimal</strong><em> </em>policy.</p><p>Even when you have the ability to find <em>optimal </em>policies, it is very useful to be able to quickly estimate the outcome of <em>any</em> policy.</p><p>For instance, in business settings there’s always interest in <em>simple</em> policies that <em>apply the same action to every customer</em>. These policies are easy to understand and to execute, so business leaders naturally prefer them. To help decide if they should go with a simple policy or not, they may want to know how much outcome they are “giving up” by using a simple policy instead of a complex one. If the drop in expected outcome isn’t that much, we may as well go with the simple policy, right?</p><p>(BTW, simple policies are everywhere. In clinical trials, for example, we are interested in the <em>difference</em> in average outcomes between <em>two</em> simple policies: (1) give everyone<em> </em>the medicine, and (2) give everyone<em> </em>the placebo)</p><p>Let’s return to the Netflix customer churn example we have been working with in this blog series.</p><p>Suppose your boss comes to you with an idea for a new policy:</p><blockquote>If a customer binge-watched a show in the past month, “do nothing”.</blockquote><blockquote>Otherwise, if the customer’s viewing hours last month are 10–30% less than the previous month, offer “2 more devices”. If the customer’s viewing hours last month dropped by more than 30% from the previous month, offer “20% off”.</blockquote><blockquote>If none of these criteria apply, “do nothing”.</blockquote><p>Sure, you can do an experiment to estimate the average outcome of this policy: take a random sample of customers and run the policy on them, and measure the outcomes. But this will take time and effort.</p><p>There’s a faster way. You can use the dataset we prepared in <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a> to quickly estimate the average outcome of your boss’s brainwave <em>without running an experiment.</em></p><p>The key to this is a magical thing called the <a href="https://en.wikipedia.org/wiki/Horvitz%E2%80%93Thompson_estimator">Horvitz-Thompson Estimator</a> and here’s how it works.</p><p>Let’s start with the dataset assembled in <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9RVI_NuAiQFFGETOdwH3g.png" /></figure><p>For every customer in the dataset above, determine the action specified by the proposed policy (in practice, this should be a straightforward SQL query or something similar).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa7LHjFhekgnsmrPcr-qvg.png" /></figure><p>Next, add an “Adjusted Outcome” column to the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glTgVvOtQZ_xa7g-SQQvOw.png" /></figure><p>Now for the clever part: <em>for every customer where the actual action that was assigned matches the action specified by the new policy, divide the outcome by the probability of the assigned action and stick it in the adjusted outcome column.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kO_PeYU7kVvAil6FvRfsug.png" /></figure><p>For example, the actual action that was assigned <em>and</em> the action specified by the new policy are both “20% off” for the third customer, so we take the outcome 1.0 and divide by the probability of being assigned the “20% off” action (which is 92%) to get an adjusted outcome of 1.0/0.92 = 1.1 (similarly for the other three rows marked with red boxes).</p><p>For all the <em>other</em> rows in the dataset (i.e. where the actions <em>don’t</em> match), assign 0.0 as the adjusted outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LR7WwPapUTPzwY1TB4rxlg.png" /></figure><p>The “Adjusted Outcome” column is complete. Now, simply take the average of this column and voila! You have an estimate of the average outcome of your boss’ policy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZWBDC6JlE2hfaUVeOkaZA.png" /></figure><p>A couple of quick notes:</p><ul><li>We are dividing by probabilities to calculate the adjusted outcome. Now you understand why I insisted in <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a> that every probability in the data collection policy needs to be non-zero.</li><li>In the same vein, it is advisable to make sure the probabilities in your data collection policy aren’t too small. Dividing outcomes by very small probabilities will inflate the adjusted outcome numbers and make the estimate less reliable.</li><li>There is a ‘normalized’ version of the Horvitz-Thompson Estimator called the Hajek Estimator that has better statistical properties. Instead of finding the simple average of the ‘Adjusted Outcome’ column, we divide the sum of the column by the sum of the reciprocals of the probabilities used to adjust the outcomes (i.e.,divide by 1/0.92 + 1/0.45 + 1/0.22 + … + 1/0.56). See Section 5.1 of <a href="http://arxiv.org/abs/2010.15835">Yang et al (2020)</a> for more.</li><li>I want to re-iterate a caveat from <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>: if the training dataset was assembled not via a randomized experiment but from historical observational data, the customers in the dataset will not be a random sample and that can seriously bias the estimated outcome. So take those numbers with a “pinch of salt”.</li></ul><p>Given this ability to evaluate any policy, you can search for a good policy by brainstorming ideas for new polices, estimating how good they are, and trying to improve them.</p><p>Or, you can <em>directly</em> find an <strong>optimal</strong> policy. In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">Part 4</a>, we will do exactly that.</p><p>For the mathematically curious, here’s my attempt at a clearer version of the <a href="https://en.wikipedia.org/wiki/Horvitz%E2%80%93Thompson_estimator#Proof_of_Horvitz-Thompson_Unbiased_Estimation_of_the_Mean">proof on the Wikipedia page</a> that shows how the Horvitz-Thompson Estimator unbiasedly estimates the outcome of any policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qkQYQk6au3Fu3sNrp8X2HQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U6bQLj_F-7R9h2KjkBiUw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1PYIzU-tg4zXNhrKPAjTQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa56c974a505" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505">From Prediction to Action — How to Learn Optimal Policies From Data (3/4)</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[From Prediction to Action — How to Learn Optimal Policies From Data (2/4)]]></title>
            <link>https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fc46ba8f3d0</guid>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[contextual-bandit]]></category>
            <category><![CDATA[uplift-modeling]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 19:58:51 GMT</pubDate>
            <atom:updated>2025-03-26T13:32:47.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1OxluLNp0GuEAvmi" /><figcaption>Photo by <a href="https://unsplash.com/@elsbethcat?utm_source=medium&amp;utm_medium=referral">Beth Macdonald</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">Part 1</a>, we discussed the need to learn <em>optimal</em> policies from data. Policy optimization covers a <em>vast</em> range of practical situations (e.g., arguably, <em>every</em> personalization problem is a policy optimization problem) and we briefly looked at examples from healthcare, churn prevention, target marketing and city government.</p><p>To learn optimal policies, we need to assemble the <em>right</em> data. In this post, we will describe how to create a dataset so that it is suited for policy learning.</p><p>With the right dataset at hand:</p><ul><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505">Part 3</a>, we will learn a simple (and, in my opinion, <em>magical</em>) way to estimate the outcome of <strong><em>any</em></strong> policy.</li><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">Part 4</a>, we will learn how to find an <strong>optimal</strong><em> </em>policy.</li></ul><p>Let’s recap the problem definition from <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">Part 1</a>. You have:</p><ul><li>a set of customers (I am using ‘customer’ broadly to refer to an entity that you want to apply an action to. For instance, it could be a patient, a website visitor, a prospect, a business, a geographic region, …you get the idea). All the relevant information about the customer’s attributes, behavior and other contextual information is represented as a vector of features.</li><li>a set of possible actions</li><li>the outcome <em>to you</em> when a customer is targeted with an action (importantly, different customers may respond differently to actions)</li><li>Your objective: for each customer, find the action with the best outcome. Equivalently stated, learn a function that assigns the <strong>best</strong> action to each customer feature vector. This is called an <strong>optimal</strong> <strong>policy</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*1PHJUgT2Q6tfzAMIPGbJrA.png" /></figure><h3>Strategies for Dataset Creation</h3><p>Let’s start with perhaps the most important thing to remember about dataset creation for policy optimization:</p><blockquote>The ideal dataset for policy learning comes from a randomized experiment.</blockquote><p>If you have the freedom to run such an experiment, great!</p><p>But if you can’t run a randomized experiment, don’t despair — if you have access to past <em>observational</em> data, you can still create a training dataset from it.</p><p>We will cover both scenarios in detail in this post, starting with the happy scenario where you <em>can</em> run a randomized experiment. We will see that there is much more flexibility here than may be apparent at first glance.</p><h3><strong><em>Dataset Creation via a Randomized Experiment</em></strong></h3><p>Creating a training dataset by means of a randomized experiment is a 3-step process.</p><ul><li><strong>Step1</strong>: select a <em>random</em> sample of customers from the customer base.</li><li><strong>Step 2</strong>: decide <em>how to randomly assign actions</em> to each customer in the sample</li><li><strong>Step 3</strong>: run the experiment and collect data on outcomes</li></ul><p>Step 1 is straightforward so let’s turn to Step 2.</p><p>Referring back to the Netflix churn management example from <a href="https://towardsdatascience.com/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">Part 1</a>, recall that we considered three actions: “20% off for next year”, “stream two more devices” and “do nothing”.</p><p>For the moment, let’s assume that we have only two actions, “stream 2 more devices” or “do nothing”.</p><p>What’s the simplest way to randomly assign one of these two actions to every customer in the sample? <em>For every customer, toss a fair coin. If it comes up heads, assign “2 more devices” and if it comes up tails, assign “do nothing”.</em></p><p>This “scheme” can be described as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*oNI9Pfh4M4Rd8MO-0ngEjQ.png" /></figure><p>More generally, if we have N actions, <em>we can make every action equally likely for every customer. </em>For the 3-action Netflix example, our scheme will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5VdcKbsGA5IdJghq-YBFfQ.png" /></figure><p>Here’s where it gets interesting.</p><p><em>It turns out that we can choose </em><strong><em>any</em></strong><em> probability for each customer-action combination, as long as two conditions are satisfied:</em></p><ul><li><strong>For any customer, the probabilities of all the actions must add up to 1.0</strong> (i.e., the sum of the probabilities in each row must be 1.0). This just ensures that <em>exactly one </em>action is assigned to each customer.</li><li><strong>Every probability must be non-zero</strong>. This ensures that <em>every</em> action has a chance of being assigned to a customer.</li></ul><p><strong><em>If we work with probabilities satisfying these two conditions, the resulting datasets can be safely used for policy evaluation and policy optimization.</em></strong></p><p>Here’s an example of probabilities that satisfy the two conditions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*gtqPS6DHaGuxYYVbSZ9pvw.png" /></figure><p>I want to draw your attention to two things:</p><ul><li>Notice that the <em>probabilities are different for different customers</em>. This is totally fine, since it doesn’t violate the two conditions above. In fact, this ability to choose different probabilities for different customers gives us enormous flexibility, as we will see shortly.</li><li>Notice that the table above is a kind of <strong>policy</strong>: given <em>x</em>, instead of picking a specific action, you pick an action randomly <em>according to the probabilities defined for </em><strong><em>that</em></strong><em> x. </em>A policy that satisfies the two conditions above is called a <em>behavior policy</em> in the Reinforcement Learning literature but I will call it a <strong><em>data collection policy </em></strong>(since I find the latter name easier to remember)</li></ul><p>The freedom to choose different probabilities for different customers can be very useful in practice.</p><p>A common situation is when we don’t want to waste an “expensive” action (e.g., a 50% discount!) on customers who are unlikely to need them.</p><p>Concretely, let’s say we want to apply the “20% off for next year” action only to customers with a high probability of cancellation, and not to others, since we suspect that customers at low risk may just pocket the reward and we’d have wasted an expensive discount on them. But we don’t care how often “stream two more devices” and “do nothing” are applied.</p><p>We can easily accommodate this business requirement in our data collection policy. Here’s one way.</p><p>First, we use historical data to build a model to predict the probability of cancellation for every customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*x0EWXvf1TbLs_glTG9N7YQ.png" /></figure><p>You can use any classification approach of your choice to build this model as long as it provides a probability prediction rather than just a 0–1 class prediction. Run this model on your customer sample to get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*2vADsxLWsJMhyvlWE2ouPQ.png" /></figure><p>Now, consider a customer in the sample whose predicted probability of cancellation is <em>p</em>. For this customer, set the probability of being assigned the “20% off for next year” action to <em>p. </em>Take the remaining probability (i.e., <em>1-</em> <em>p</em>) and split it equally among the other actions: “stream two more devices” gets a probability of <em>(1-p)/2</em> and “do nothing” gets <em>(1-p)/2</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPVksGzZuwKKuuSk6cRCUA.png" /></figure><p>It is easy to confirm that this is a valid data collection policy: all three numbers are non-zero and, of course, they add up to 1.0 (For now, I am assuming that the prediction model doesn’t output probabilities that are <em>exactly</em> equal to 1.0 or 0.0. I will revisit this assumption later in the post).</p><p>Applying this logic, we get this data collection policy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMiajcuXmiX9NsB9VCzETQ.png" /></figure><p>The probability of cancellation for the first customer is 70% so “20% off” gets a probability of 70%, “stream two more devices” gets 15% and “do nothing” gets 15%.</p><p>You can see that customers with a low predicted probability of cancellation (e.g., the last customer in the example) have a low chance of getting the expensive “20% off” discount, which is what we wanted.</p><p>This is just one example of how we can flexibly define a data collection policy to accommodate business considerations. Feel free to use your creativity and knowledge of the business to define other data collection policies. Just make sure that the probabilities are non-zero and that they add up to 1.0 for every customer in the sample.</p><p>Once a valid data collection policy has been specified, we reach Step 3: running the experiment and measuring the outcomes.</p><p>This step is straightforward:</p><blockquote>For each customer in your sample, randomly select an action according to that customer’s probabilities,<em> </em>apply the selected action to that customer<em>, </em>and measure the outcome.</blockquote><p>If you know how to do random sampling, picking an action according to the probabilities<em> </em>is easy and there are many ways to do it. For a customer with 70%-15%-15% probabilities for the three actions, for example, generate a uniform random number in the 0–1 range and if the value is between 0.0–0.7, pick “20% off for next year”, if it is between 0.70–0.85, pick “stream two more devices”, and if it is between 0.85–1.0, pick “do nothing”.</p><p>When the experiment concludes, the final data will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7WfWz-duNU4cfi_rEsLcg.png" /></figure><p>Note that we have appended two more columns: the actual action that was assigned to each customer, and the value of the outcome. For simplicity, I am showing a binary outcome but you can use anything (e.g., next-year’s profit).</p><h3>Dataset Creation from <strong>Observational Data</strong></h3><p>Let’s now consider the situation where it is difficult for you to run a randomized experiment to collect data. But we can still build a dataset that can be used for policy evaluation and learning, <strong>IF</strong> data on actions applied to customers in the past and the resulting outcomes <em>are</em> available (see the table below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*3Sks5vtSJMFnxdcfsPUKIw.png" /></figure><p>There are two significant caveats we need to keep in mind here:</p><ul><li>The customers for whom we have historical data on actions and outcomes data may not be a random sample of the customer base.</li><li>While you can see which action was assigned to each customer, there’s no information on how exactly the action was chosen for that customer. <em>A random data collection policy may or may not have been used — we don’t know.</em></li></ul><p><em>Because of the lack of randomization described above, the results of policy evaluation (to be covered in Part 3) and policy optimization (to be covered in Part 4) must be taken “with a pinch of salt” i.e., with some measure of skepticism.</em></p><p>With that warning out of the way, let’s look at how to build a training dataset from observational data. The basic idea is to “impute” the customer-action probabilities from the historical dataset i.e. to fill in the <strong>missing</strong> values in this table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntIyvL_i5ROHDD8weh0AFA.png" /></figure><p>How? By using the actual action that was assigned as a <strong>class label</strong> …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*bjLuV5azr7IjktNwBoCVww.png" /></figure><p>… and building a multi-class classification model with the above dataset!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*-1lTqTSbek8x8UlQezkQJg.png" /></figure><p>Now we can fill in the table with the predicted probabilities from the model …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ik6lUGzDIGuR6SI7svRv2A.png" /></figure><p>… and our training dataset is ready.</p><p>You may be thinking, “Not so fast. What if the predictive model returns probabilities that are <em>exactly</em> zero for certain customer-action combinations? Wouldn’t that violate the no-zero-probabilities condition we specified early on?”</p><p>You are absolutely right, it would violate that condition and we can’t use the probabilities.</p><p>Before we look at how to address this issue, it is worth pointing out that this is not uncommon in practice. In many business situations, “common-sense business rules” are used and can lead to historical data where predicted probabilities can be zero (BTW, you can think of “business rule” as just another name for “policy” in this context).</p><p>Consider this example of a business rule:</p><blockquote>If a customer binge-watched a show in the past month, “do nothing”.</blockquote><blockquote>Otherwise: if the customer’s viewing hours last month are 0–30% less than the previous month, offer “2 more devices”. If the customer’s viewing hours last month dropped by more than 30% from the previous month, offer “20% off”.</blockquote><p>Let’s assume that the feature vector <em>x</em> has features that represent binge-watching, % change in viewing hours etc.</p><p>If the above rule/policy is in use, historical data will look like the following table (to make the table easier to read, I have grouped the records so that the binge-watchers are together, the 0–30% records are together and so on).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JWJqruMWTcsNKQVM0sTj7g.png" /></figure><p>Now, if you run a <a href="https://en.wikipedia.org/wiki/Decision_tree_learning">classification tree</a> algorithm on this historical data using <em>x</em> as the input and the assigned action as the target class label (as explained earlier in the post), it will likely “reverse engineer” your policy from the data and generate a tree like this …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qB37Qi8MyvOy-KeEBAuAWw.png" /></figure><p>… leading to predicted probabilities that are exactly 0.0 and 1.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5YW6JZcwPK3O7lh20Mb6bA.png" /></figure><p><em>Since this violates the no-zero-probabilities condition, we can’t use this dataset for policy evaluation and optimization.</em></p><p>What can we do?</p><p>First, the bad news: to handle this, we <em>have</em> to run a randomized experiment and collect fresh data.</p><p>But there is a possibility of good news. If you can’t run a randomized experiment because you don’t have the infrastructure to do so, I am afraid I don’t have a solution :-(</p><p>But if the reason is that</p><ul><li>your business stakeholders aren’t used to randomized experimentation <em>or</em></li><li>they are happy with the current policy and have a “if it ain’t broke, don’t fix it” mindset <em>or</em></li><li>they feel that changing the current policy is risky,</li></ul><p>you may be able to convince them with the following “gentle” proposal.</p><blockquote>Let me run this experiment on a customer sample: <strong>For 90% of customers in the sample, we will follow the current policy.</strong> For 10% of the customers, we will pick an action randomly.</blockquote><p>This popular approach (called <a href="https://en.wikipedia.org/wiki/Multi-armed_bandit"><em>epsilon-greedy</em></a><em>) </em>may be palatable to the business since the “risk” of something going wrong is less than 10%.</p><p>More formally:</p><ul><li>set <em>epsilon</em> to a small fraction (e.g., 0.1)</li><li>for every customer, draw from a uniform (0,1) random variable. If its values is less than <em>epilson </em>(e.g., less than 0.1), randomly pick an action with equal probability and assign that action to the customer. If not, use the current policy to decide what action to assign to that customer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gesVZ38_3u26B6-rmei6Ag.png" /></figure><p>As you can see, 1- <em>epsilon</em>% (e.g., 90%) of the time, this approach will pick the action dictated by the current policy. But <em>epsilon</em>% (e.g., 10%) of the time, this approach will pick one of the three actions with equal probability.</p><p>Equivalently, you can think of this as combining two policies with a 90%–10% weighted average…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CPFL8GCYnrbu8COyrcdxg.png" /></figure><p>… to get a new one that satisfies the “no zero probabilities” condition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*GF3e3QCYWVW4YODnk37rqg.png" /></figure><p>By keeping <em>epsilon</em> small, you can assure business stakeholders that you aren’t taking a big risk or incurring a big expense in the name of data collection. This approach can be a good way to “ease” business stakeholders into the experimentation mindset. And as they get more used to it and can tolerate more risk, you can set <em>epsilon</em> to a higher value.</p><p>(BTW, what if we have never tried an action historically and therefore have no data about its outcomes? Just add the new action to the “randomly assign an action” branch of <em>epsilon</em>-greedy and start collecting data)</p><p>At this point, using the approaches described above, let’s say you have assembled a dataset like this, with the probabilities all non-zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9RVI_NuAiQFFGETOdwH3g.png" /></figure><p>Or, more generally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jpesc9rp9-bFZ8xsBVV3GQ.png" /></figure><p>This dataset is a very useful thing to have.</p><p>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505">Part 3</a>, we will learn how to use this dataset to quickly estimate the outcome of <strong><em>any</em></strong> policy (i.e., policy evaluation<em>) without running any experiments.</em></p><p>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">Part 4</a>, we will learn how to use it to find an <strong><em>optimal</em></strong> policy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fc46ba8f3d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">From Prediction to Action — How to Learn Optimal Policies From Data (2/4)</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[From Prediction to Action — How to Learn Optimal Policies From Data (Part 1)]]></title>
            <link>https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1edbfdcb725d</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[uplift-modeling]]></category>
            <category><![CDATA[contextual-bandit]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 15:45:24 GMT</pubDate>
            <atom:updated>2025-03-26T13:33:53.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Prediction to Action — How to Learn Optimal Policies From Data (1/4)</h3><figure><img alt="Which way to go?" src="https://cdn-images-1.medium.com/max/1024/0*icYPPzeLs4vp65Sb" /><figcaption>Photo by <a href="https://unsplash.com/@garri?utm_source=medium&amp;utm_medium=referral">Vladislav Babienko</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In data science work, we build models to make predictions. And using these predictions, we make decisions or take action.</p><p>Sometimes, the relationship between prediction and action is straightforward:</p><ul><li>you are trying to decide as you leave home for work if you should take an umbrella or not. You predict the chance of rain. If it is high enough, you take an umbrella. If not, you leave the umbrella at home (<a href="https://pubs.aeaweb.org/doi/10.1257/aer.p20151023">source</a>)</li><li>you are trying to decide if a person in an image is X. If the predicted probability is high enough, you tag the image with the person’s name. If not, you leave it untagged.</li></ul><p>Other times, the relationship between prediction and action is more complicated.</p><p>Let’s say you are a data scientist working for a subscription business like Netflix. You want to prevent customers from cancelling their monthly subscription by offering them incentives to stay.</p><p>This is the well-known <a href="https://blog.hubspot.com/service/what-is-customer-churn">churn</a> problem and a standard Data Science/Machine Learning approach would be as follows.</p><p>First collect historical data on customers who cancelled and customers who didn’t. Use their attributes, their interactions with the business etc. to form a “feature vector” for each customer. Add a flag that indicates if the customer cancelled or not, and create a dataset like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*RQvcs8MC65oI2WU0ytubOw.png" /></figure><p>With this dataset, build a model (e.g., <a href="https://en.wikipedia.org/wiki/Logistic_regression">logistic regression</a>) that, given a customer’s feature vector, predicts the probability that they will cancel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*FqEKVXP5l8_du-JUPsAbog.png" /></figure><p>This may be a very complex model. It may have hundreds or thousands of features for each customer (i.e. each x may be a really long vector) and may have been built using state-of-the-art methods (e.g., <a href="https://en.wikipedia.org/wiki/Deep_learning">Deep Learning</a>, <a href="https://en.wikipedia.org/wiki/XGBoost">XGBoost</a>)</p><p>But what should you <strong>do</strong> with such a model?</p><p>Should you contact customers with a high predicted probability of churning and offer them a reward or discount if they renew?</p><p>This is a reasonable approach and is widely used. It will work for <em>some</em> customers but maybe not for all customers (<a href="https://doi.org/10.1509/jmr.16.0163">reference</a>).</p><ul><li>Some customers will ignore the reward and cancel anyway.</li><li>Others may not have been thinking of leaving at all but will gladly pocket the reward and stay — you just wasted the reward on them.</li><li>For some others who may not have been thinking of leaving, maybe your reward reminded them that they have not been using your product/service all that much and they might click the ‘cancel’ button.</li></ul><p>And if you have more than one possible action, it gets even more complicated. C<strong>ustomers may react differently to different actions</strong>. Customer Sally may renew if offered a “get 20% off your monthly bill if you renew for a year” reward but not if offered a “stream 2 more devices for free” reward. For customer Albert, it may be the opposite.</p><p><strong>Imagine if you could predict the probability of churn when a customer is targeted with <em>each</em> possible action you could take, including the action of “do nothing”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*YzGT3A-0n_rw32jJ_LSCTA.png" /></figure><p>Of course, estimating the probability of churn for each action is just the starting point. In a business setting, you may care ultimately about a financial outcome — for example, the expected profit from each customer over the next 12 months. If you know the cost/revenue impact of each action, you can transform the model above to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*M9iVdQ7xVBjUKE_geBzVLw.png" /></figure><p>With this model in hand, for any customer, you can predict the expected outcome for each action, and “read off” the best action for that customer (i.e. find the maximum of 3 numbers!)</p><p>We will learn later how to build a model like the one above. But first, let’s step back and abstract out the key elements of the churn problem.</p><ul><li>a set of customers (I am using ‘customer’ broadly to refer to an entity that you want to apply an action to. For instance, it could be a patient, a website visitor, a prospect, a business, a geographic region, …you get the idea). All the relevant information about the customer’s attributes, behavior and other contextual information is represented as a vector of features.</li><li>a set of possible actions</li><li>the outcome <em>to you</em> when a customer is targeted with an action (importantly, different customers may respond differently to actions)</li><li>Your objective: for each customer, find the action with the best outcome</li></ul><p>Let’s pause for a couple of quick definitions.</p><p>A function that assigns an action to each feature vector is called a <strong>policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*mvY2oKZW1SnfxvEVDAt3xg.png" /></figure><p>A function that assigns the <strong>best</strong> action to each feature vector is an <strong>optimal</strong> <strong>policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*A_JJMhGLMcOQSxwqh7QuQA.png" /></figure><p><strong>We want to learn optimal policies</strong>.</p><p>Policy optimization problems are extremely common.</p><ul><li><strong>Personalized medicine</strong>: For a medical condition, there are 4 possible treatments. The effectiveness of each treatment may vary across patients, depending on each patient’s characteristics and medical history. What’s the <strong><em>optimal treatment policy</em></strong> i.e., which treatment should we “apply” to each patient, so as to maximize positive health outcomes?</li><li><strong>Campaign Targeting</strong>: For e-commerce visitors who abandon a shopping cart, we want to email them one of 3 offers: 20% off, free shipping, gift with purchase. Different shoppers will respond differently to these offers. What’s the <strong><em>optimal targeting policy</em></strong> i.e., which offer to “apply” to each shopper to maximize expected profit? (the churn problem described above is also an instance of “Campaign Targeting”)</li><li><strong>Health/Safety Monitoring</strong>: Cities check business establishments for compliance with health and safety regulations by sending inspectors. Not every building can be checked in every time period with available staff so we need an <strong><em>optimal inspection policy: </em></strong>for each establishment, pick one of two actions — inspect this time period, don’t inspect this time period — so as to maximize overall safety. It is not just a matter of predicting which buildings are more likely to have violations. The “response” of a building owner to fix a violation that’s found by an inspector is important.</li></ul><blockquote>A building may be at higher risk of fire due to old wiring, but other considerations make it difficult to replace the wiring. Other units may have lower predicted risk, but it may be easy and inexpensive to make substantial improvements. Another consideration is responsiveness; if violations entail fines, some firms may be more sensitive to the prospect of fines than others.</blockquote><blockquote>Source: <a href="https://www.sciencemag.org/lookup/doi/10.1126/science.aal4321&#39;">Overview article</a> by <a href="https://www.gsb.stanford.edu/faculty-research/faculty/susan-athey">Prof. Susan Athey</a> of Stanford, which I recommend reading in its entirety.</blockquote><p>OK, how do we learn optimal policies?</p><p>Let’s look at perhaps the most straightforward situation first.</p><p>Returning to the churn example, let’s imagine that we have data from a <strong>randomized experiment</strong>: a sample of customers were <strong>randomly</strong> chosen and then <strong>randomly</strong> assigned to one of the three actions — 20% off, stream two more devices, and do nothing — and their renewal/cancel response was logged.</p><p>In this lucky situation, we have these three nice datasets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*U0EvA1Org_-A9zQV94C9TQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*Mx4cQ2qB2VzAR9cacWjsrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*OSt26WgAy6cNKRVJGeWYaQ.png" /></figure><p>(Please note that the customers in these three groups are different. I am using the same <em>x</em> symbols for the Customer Feature Vector column in all three tables, just for convenience)</p><p>We can build three standard classification models now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFNfAqRrFnnz243FTptn1A.png" /></figure><p>With these three models in hand, finding the optimal policy is easy: run any customer’s <em>x </em>through each model, get the three predicted cancellation probabilities, translate them to expected profit (or whatever financial outcome you care about), and pick the action with the highest expected profit.</p><p>Nice. But as I mentioned earlier, this is the most straightforward situation.</p><p>In practice, we may not be so fortunate.</p><p>What if there <em>is</em> data but it is not from a randomized experiment that you can safely use for modeling. Maybe there’s only observational data from the past where offers were made not to a random sample of customers, but only those likely to cancel (for instance). Building a model on this data and applying it to <em>all</em> customers may lead to bad predictions.</p><p>What if an action — say, stream two more devices for free — <em>has never been tried before</em>, so there’s no data on how it affects cancellation behavior. Creative businesspeople are always coming up with new actions/tactics/strategies to try so this is a real possibility.</p><p>We need to handle these and other issues carefully.</p><p>But not to worry :-). This problem and its variants have been studied extensively in many fields — <a href="https://en.wikipedia.org/wiki/Causal_inference">Causal Inference</a>, <a href="https://en.wikipedia.org/wiki/Econometrics">Econometrics</a>, <a href="https://en.wikipedia.org/wiki/Uplift_modelling">Uplift Modeling</a> in Marketing, and (especially) <a href="https://vowpalwabbit.org/tutorials/contextual_bandits.html">Contextual Bandits/Reinforcement Learning</a> — and many practical and elegant approaches have been devised. These techniques typically combine prediction models (classification/regression) with smart training-data collection via randomized experiments.</p><p>In my opinion, policy evaluation and policy optimization using these techniques is a powerful but under-appreciated and under-utilized data science superpower.</p><p>In Parts 2–3–4, we will dive in and acquire this superpower :-)</p><ul><li>In <a href="https://medium.com/data-science/from-making-predictions-to-optimizing-actions-an-introduction-to-policy-learning-2-4-9fc46ba8f3d0">Part 2</a>, we will describe how to create a dataset so that it is suited for policy learning.</li><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-3-4-aa56c974a505">Part 3</a>, we will learn a simple (and, in my opinion, <em>magical</em>) way to estimate the outcome of <strong><em>any</em></strong> policy.</li><li>In <a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-4-4-14c63cc0c938">Part 4</a>, we will learn how to find an <strong>optimal</strong><em> </em>policy.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1edbfdcb725d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/from-prediction-to-action-how-to-learn-optimal-policies-from-data-part-1-1edbfdcb725d">From Prediction to Action — How to Learn Optimal Policies From Data (Part 1)</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[Lessons from a Deep Learning Master]]></title>
            <link>https://medium.com/data-science/lessons-from-a-deep-learning-master-1e38404dd2d5?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e38404dd2d5</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 19:55:20 GMT</pubDate>
            <atom:updated>2020-07-17T20:00:07.554Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*21TUp9uCW465Td7I" /><figcaption>Photo by <a href="https://unsplash.com/@vbk_media?utm_source=medium&amp;utm_medium=referral">Valentin B. Kremer</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://en.wikipedia.org/wiki/Yoshua_Bengio">Yoshua Bengio</a> is a Deep Learning legend and won the <a href="https://awards.acm.org/about/2018-turing">Turing Award in 2018</a>, along with Geoff Hinton and Yann LeCun.</p><p>In this short post, I want to highlight for you some clever things that Yoshua and his collaborators did to win a <a href="https://www.kaggle.com/c/pkdd-15-predict-taxi-service-trajectory-i">Machine Learning competition</a> from a field of 381 competing teams. Perhaps these ideas will be useful for your own work.</p><p>In a world where powerful Deep Learning frameworks (e.g., TensorFlow, PyTorch) are a free download away, their <a href="http://arxiv.org/abs/1508.00021">competition-winning approach</a> demonstrates nicely that your edge may come from <strong>how well you model the <em>specifics</em> of your problem.</strong></p><p>(Caveat: This work was done in 2015. Given all the advancements in Deep Learning and computing hardware since then, Yoshua and team would probably solve the problem differently if the competition were held today)</p><p>The teams participating in the competition were given a dataset of all the <em>taxi trips</em> undertaken over a full year in the city of Porto in Portugal.</p><p>There were 1.7 million trips in the training dataset and for each trip, the important data elements were:</p><ul><li>GPS coordinates — latitude and longitude — of the taxi’s location measured every 15 seconds from the start of the trip to the finish. The first latitude-longitude pair is the starting point of the trip and the final latitude-longitude is the destination of the trip. For example, a taxi’s location at the start of a trip, 15 seconds later and 30 seconds later would look like this: [-8.578719,41.156271],[-8.578629,41.157693],[-8.578521,41.159439].</li><li>the timestamp at the beginning of the trip</li><li>taxi ID</li><li>client ID (if the client requested the taxi by phone) or taxi-stand ID (if they got into the taxi at a taxi stand)</li></ul><p>The challenge given to the participants is simply stated:</p><blockquote>Given a <strong><em>partial</em></strong> trip (i.e., the latitude-longitude of the starting point and the next several consecutive points) and time/ID metadata, <strong>predict the latitude-longitude of the final destination.</strong></blockquote><p>For example, let’s say a taxi trip started at the Sao Bento Station and ended at the Jardins do Palacio de Cristal, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1wPkydJz3g_VfHMQR0sxw.png" /></figure><p>A partial trip would include the origin point and might be something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRtCjxktDDQjP3gig2INbg.png" /></figure><p>The test dataset had 320 partial trips. The evaluation metric was the distance between the predicted destination and the actual destination, averaged over the trips in the test dataset.</p><p>But the predicted and actual destinations are points on the surface of the earth (not points on a plane), so the distance between them is calculated NOT with the euclidean distance but with something called the <a href="https://en.wikipedia.org/wiki/Haversine_formula"><em>Haversine</em> <em>distance</em></a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z7woTwJbtlbAQ8fJD-hx9A.png" /><figcaption><a href="https://arxiv.org/abs/1508.00021">https://arxiv.org/abs/1508.00021</a></figcaption></figure><p>Looks simple, right? :-)</p><p>This is a structured data problem (i.e., no images, audio etc) so if you want to use a neural network approach, a reasonable starting point would be a basic network (an <a href="https://en.wikipedia.org/wiki/Multilayer_perceptron">MLP</a>) with a hidden layer and two output nodes, one for the latitude and one for the longitude of the destination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*3KiwCowf0or0-JEBA_3lYg.png" /></figure><p>But complications arise immediately:</p><ul><li>Since different trips may have different durations, the number of latitude-longitude pairs in each trip will vary and therefore each training example has a <em>variable</em> number of inputs. For example, a 10-minute ride will have about 40 latitude-longitude pairs while a 30-minute ride will have an input that is three times as long. How do we handle a varying number of inputs?</li><li>That Haversine function looks scary. It <em>is</em> differentiable so maybe optimizing it as-is will just work? We will see.</li><li>Our two output nodes predict latitude and longitude. Maybe this will work just fine but there are <em>only</em> 320 observations in the test dataset so even a few bad predictions can wreck the evaluation metric. Furthermore, predicting latitude and longitude directly doesn’t take into account the fact that popular destinations (e.g., the Sao Bento station) will occur more frequently in the data and therefore getting them right is very important.</li></ul><p>Let’s dive in and see how Yoshua and team solved these problems.</p><p><strong>Problem</strong>: Varying-length input</p><p>(If you are familiar with <a href="https://en.wikipedia.org/wiki/Recurrent_neural_network">Recurrent Neural Networks</a> (RNNs), you would have immediately recognized their applicability to this problem. Indeed, in their <a href="http://arxiv.org/abs/1508.00021">paper</a>, Yoshua and co-authors explore a few different variants of RNNs to address this issue but their competition-winning model didn’t use RNNs; it used the simple idea described below)</p><p><strong>Solution</strong>:</p><p>The solution that worked best was incredibly simple.</p><blockquote>Concatenate the first 5 coordinates and the last 5 coordinates of the input. If the input has fewer than 10 coordinates, still take the first 5 and the last 5 — it is ok that they overlap. Finally, if the partial trip has fewer than 5 coordinates, just repeat the first or the last coordinate till you get to 10 coordinates.</blockquote><p>For example, from this ‘raw’ input …</p><p>[[-8.611794,41.140557],[-8.611785,41.140575],[-8.612001,41.140566],[-8.612622,41.140503],[-8.613702,41.140341],[-8.614665,41.140386],[-8.615844,41.140485],[-8.61561,41.140683],[-8.614566,41.141088],[-8.614395,41.141979],[-8.613936,41.142942],[-8.612793,41.143851],[-8.611488,41.144787],[-8.610543,41.144391],[-8.610282,41.143536],[-8.610255,41.143401],[-8.608824,41.143239],[-8.608419,41.143149],[-8.606565,41.142348],[-8.605179,41.143446],[-8.604549,41.144796],[-8.604297,41.1453],[-8.603505,41.145561],[-8.602488,41.145633],[-8.601039,41.145759],[-8.600436,41.146443],[-8.599977,41.147289],[-8.598681,41.14827],[-8.598303,41.148423],[-8.598618,41.149467],[-8.597529,41.151294],[-8.596161,41.153679],[-8.594838,41.155983],[-8.594163,41.157135],[-8.593002,41.159187],[-8.591454,41.161608],[-8.589924,41.163453],[-8.589402,41.163309]]</p><p>… only the <strong>bolded</strong> coordinates would be used:</p><p><strong>[[-8.611794,41.140557],[-8.611785,41.140575],[-8.612001,41.140566],[-8.612622,41.140503],[-8.613702,41.140341]</strong>,[-8.614665,41.140386],[-8.615844,41.140485],[-8.61561,41.140683],[-8.614566,41.141088],[-8.614395,41.141979],[-8.613936,41.142942],[-8.612793,41.143851],[-8.611488,41.144787],[-8.610543,41.144391],[-8.610282,41.143536],[-8.610255,41.143401],[-8.608824,41.143239],[-8.608419,41.143149],[-8.606565,41.142348],[-8.605179,41.143446],[-8.604549,41.144796],[-8.604297,41.1453],[-8.603505,41.145561],[-8.602488,41.145633],[-8.601039,41.145759],[-8.600436,41.146443],[-8.599977,41.147289],[-8.598681,41.14827],[-8.598303,41.148423],[-8.598618,41.149467],[-8.597529,41.151294],[-8.596161,41.153679],[-8.594838,41.155983],<strong>[-8.594163,41.157135],[-8.593002,41.159187],[-8.591454,41.161608],[-8.589924,41.163453],[-8.589402,41.163309]]</strong></p><p>In case you are wondering why they picked 5 rather than another number, I suspect that they thought of this as a hyper-parameter <em>k</em> and tried a few different values; <em>k = 5 </em>may have turned out to be the best.</p><p><strong>Lesson learned</strong>:</p><blockquote>In problems with varying-length inputs, a carefully chosen fixed-length subset of the input may capture the input’s <strong>essence</strong>.</blockquote><p>For a taxi trip, knowing the origin point and the last point of the partial trip is probably all the information you need about the partial trip; knowing the exact path taken by the taxi between those two points is probably unnecessary.</p><p>But in other problems, knowing the beginning and end may not be enough; representing the entire path in some way may be necessary. In those cases, <em>sampling</em> the entire path at regular intervals may do the trick. Or sampling the more interesting parts of the path more often and sampling the less interesting parts of the path less often may be the right approach.</p><p>These ideas are not foolproof though: if the input is a sentence, we can’t just look at the first few words or the last few words. And sampling a fixed number of words from every sentence won’t work either; omitting a single word (e.g., the word ‘not’) may change the meaning of the sentence.</p><p>Nevertheless, Yoshua’s solution demonstrates that you may be able to come up with a simple approach that is <em>good enough for your specific problem</em> if you think about it carefully.</p><p><strong>Problem</strong>: How do we handle that intimidating Haversine distance function?</p><p><strong>Solution</strong>:</p><p>Turns out that our concern about that distance function was justified. Yoshua and team did run into trouble when they used the Haversine function, so they had to find a simpler alternative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWqvuyk4usUoj-dEZPi24Q.png" /><figcaption><a href="https://arxiv.org/abs/1508.00021">https://arxiv.org/abs/1508.00021</a></figcaption></figure><p><strong>Lesson learned:</strong></p><p>Again, this is a good example of <em>problem-specific thinking.</em></p><blockquote>They didn’t try to devise a <strong>universal</strong> approximation to the Haversine distance. Given that the problem is set in Porto, <strong>they just needed something that worked well at the scale of that city. It didn’t have to work for larger distances.</strong></blockquote><p>Once you realize this, <a href="https://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/">a little Googling</a> can lead you to the equirectangular distance, which looks a lot simpler than the Haversine.</p><p>If you are familiar with machine learning, you have probably learned the importance of making sure that your loss function accurately captures the real-world objectives you care about for your problem.</p><p>But what you may not have learned is that when your loss function is complex (as it often is), you don’t have to find an approximation that’s good <em>everywhere</em>. <em>It just has to be good enough within the scope of your problem.</em></p><p><strong>Problem</strong>: Does having two simple output nodes — one for latitude and one for longitude — work?</p><blockquote>As the destination we aim to predict is composed of two scalar values (latitude and longitude), it is natural to have two output neurons. <strong>However, we found that it was difficult to train such a simple model because it does not take into account any prior information on the distribution of the data.</strong><em>(emphasis mine) Source: </em><a href="https://arxiv.org/abs/1508.00021">https://arxiv.org/abs/1508.00021</a></blockquote><p>By “prior information on the distribution of the data”, Yoshua and team are referring to the varying popularity of different destinations (e.g., the Sao Bento train station will be more popular than a particular residential address).</p><p>Let’s see what they did! This is my favorite part of their paper.</p><p><strong>Solution</strong>:</p><p>They ran a clustering algorithm on all the final destinations in the training set and grouped them into a few thousand clusters (3,392 to be exact).</p><p>Conceptually, they went from this …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A6WWo82fS4AsRRa1nfvCOA.png" /></figure><p>… to something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YyiWc0c_l0NVSSsiB7VIDw.png" /></figure><p>(This is just for illustration. The actual clusters were probably not all of the same size and shape)</p><p>Now, instead of directly predicting the latitude-longitude of the final destination, we can think of this as a <a href="https://en.wikipedia.org/wiki/Multiclass_classification">multi-class classification</a> problem where the task is to classify the input into one of those 3,392 clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*1BH8BJhmEsppbcwf-1Qx0Q.png" /></figure><p>The final layer for a multi-class classification problem is usually a <a href="https://en.wikipedia.org/wiki/Softmax_function">softmax</a> layer, which gives you a probability distribution over all the possible output classes. In our example, the softmax layer will generate a probability for every one of the 3,392 clusters.</p><p>It is standard practice in multi-class classification to pick the class with the highest probability as the predicted output. <em>Accordingly, we can pick the highest-probability cluster and use the latitude-longitude of its center point as the predicted destination.</em></p><p>Notice how this transformation neatly takes into account the ‘<em>prior information on the distribution of the data’</em>: the clusters containing popular destinations will occur more frequently in the training set and will therefore, on average, have higher predicted probabilities.</p><p>This sounds pretty good, right?</p><p>But what if an actual destination is at the corner of a cluster, far from the cluster center? Since we are using the cluster center as the prediction, the distance between our prediction and the actual destination will be non-zero for sure and may be sizable.</p><p>One way to get around this issue is to increase the number of clusters we use. By generating (say) 5000 clusters, each cluster gets smaller and and every point in a cluster will be closer to its center. But we now have a multi-class classification problem with many more output classes. Without sufficient training data for every cluster, we won’t be able to train a good model.</p><p>Yoshua and team devised a better way.</p><p>They multiplied the predicted cluster probabilities (i.e., the output of the softmax) by the coordinates of the cluster centers and added them up to calculate a weighted average latitude …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*S7B4mDoJogJvIyQtshbLqA.png" /><figcaption>predicted latitude</figcaption></figure><p>… and a weighted average longitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*k4FkkA-3kVaiGY4cGBfLvg.png" /><figcaption>predicted longitude</figcaption></figure><blockquote>This (probability-weighted) latitude-longitude pair is the predicted destination.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*VXSv0Pd7dJtuthQr11oRyQ.png" /></figure><p>This means, for example, that if the model thinks that two adjacent clusters are equally likely to be the final destination, the midpoint of their centers will be predicted as the final destination.</p><p>It is important to note that this final weighted-averaging step is <em>not</em> a post-processing step. <em>It has to be part of the network — </em>only then, the predicted latitude-longitude pair can be fed into the loss function, which, in turn, can be optimized to train the network.</p><p>To make this part of the network, <strong>they add a single linear layer <em>after</em> the softmax layer</strong>. This, in my opinion, was a master move :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzECNIKwMUGjXHjRr_U9zQ.png" /></figure><p>The weight matrix of this linear layer is just the cluster centers …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*tSyhgkcnYGLhrOK6iI2K7w.png" /></figure><p>… but with an important twist: <em>the weights are kept fixed during training.</em></p><p>After all, we<em> </em>already know what they are (i.e,, they aren’t randomly initialized weights, they come from the clustering algorithm) and don’t need to learn them.</p><p>In summary, Yoshua and team:</p><ul><li>first changed the problem from a two-output regression problem to a multi-class classification problem</li><li>and then changed it back to a two-output regression problem by adding a final linear layer and two output nodes</li><li>by making the cluster centers as the weight matrix for the linear layer but freezing the weights of this layer, they brought the weighted-averaging step inside the network and made end-to-end training of the network possible.</li></ul><p>Neat, right?</p><p>BTW, if you are curious about which clustering algorithm was used:</p><blockquote>The clusters were calculated with a mean-shift clustering algorithm on the destinations of all the training trajectories, returning a set of C = 3392 clusters. <em>Source: </em><a href="https://arxiv.org/abs/1508.00021">https://arxiv.org/abs/1508.00021</a></blockquote><p><strong>Lessons learned:</strong></p><ul><li>It is important to consider the prior distribution of the output values when thinking about the output layer. For classification problems, this is usually straightforward (and even automatic) but for regression problems like this one, it requires paying more attention than we normally do.</li><li>If the specifics of the problem require a particular kind of computation, define a layer to do it and include it in the network (rather than do it in an ad hoc manner outside the network) so that you can learn its parameters as part of the training process. <em>As long as</em> <em>its derivative can be calculated, it is worth a try</em>.</li><li>If the above lesson makes you wonder why Yoshua and team did the clustering <em>outside</em> the network, instead of defining a layer for it in the network and learning the best clusters as part of training the network:</li></ul><blockquote>One potential limitation of our clustering-based output layer is that the final prediction can only fall in the convex hull of the clusters. <strong>A potential solution would be to learn the clusters as parameters of the network and initialize them either randomly or from the mean-shift clusters</strong>. (emphasis mine)</blockquote><blockquote><em>Source: </em><a href="https://arxiv.org/abs/1508.00021">https://arxiv.org/abs/1508.00021</a></blockquote><p>I hope you enjoyed this peek into how a Deep Learning master thinks. If none of these lessons were new to you, congratulations — you are well on your way to Deep Learning mastery!</p><p>(If you found this article helpful, you may find <a href="https://rama100.github.io/lecture-notes/">these</a> of interest)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e38404dd2d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/lessons-from-a-deep-learning-master-1e38404dd2d5">Lessons from a Deep Learning Master</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[How to Use Causal Inference in Day-to-Day Analytical Work— Part 2 of 2]]></title>
            <link>https://medium.com/data-science/how-to-use-causal-inference-in-day-to-day-analytical-work-part-2-of-2-1824e7024cd2?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1824e7024cd2</guid>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Thu, 18 Jun 2020 17:12:28 GMT</pubDate>
            <atom:updated>2020-06-21T14:55:17.566Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*AgGXFmiFhBUMothX" /><figcaption>Source: <a href="https://www.pexels.com/photo/paper-on-gray-laptop-669617/">https://www.pexels.com/photo/paper-on-gray-laptop-669617/</a></figcaption></figure><p>In <a href="https://towardsdatascience.com/how-to-use-causal-inference-in-day-to-day-analytical-work-part-1-of-2-b5efbdbf8ab0">Part 1</a>, we looked at how to use Causal Inference to draw the right conclusions — or at least not jump to the <em>wrong</em> conclusions — from <em>observational</em> data.</p><p>We saw that <strong><em>confounders</em></strong> are often the reason why we draw the wrong conclusions and learned about a simple technique called <strong><em>stratification</em></strong> that can help us <strong><em>control for confounders</em></strong>.</p><p>In this article, we present another example of how to use stratification and then consider what to do when there are so many confounders that stratification becomes messy.</p><p>Let’s say you work at a multi-channel retailer. You have been analyzing customer-level sales data and notice the following:</p><blockquote>Customers who buy from multiple channels spend 30% more per transaction than customers who buy from a single channel.</blockquote><blockquote>Source: Inspired by <a href="http://bit.ly/2Q6BwTN">http://bit.ly/2Q6BwTN</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pWgQF4X9pYnswDLEhM1ng.png" /></figure><p>This is a pretty exciting finding because it is very <em>actionable </em>if true<em>: </em>You can put together a list of your single-channel shoppers and send them offers to entice them to buy from <em>another</em> channel the next time they shop — if a customer bought in a physical store the first time around, you can email them a 20% off <em>online-only</em> coupon. <em>If your finding is real</em>, they will spend more than they otherwise would and you can sit back and watch the money roll in :-)</p><p>It is tempting to immediately take this finding to the CEO —I mean, a 30% increase in revenue is a LOT of money — but let’s apply the checklist we defined in <a href="https://towardsdatascience.com/how-to-use-causal-inference-in-day-to-day-analytical-work-part-1-of-2-b5efbdbf8ab0">Part 1</a>.</p><p><strong>Random assignment?</strong> No. Shoppers <em>self-selected</em> themselves into the single-channel and multiple-channel groups.</p><p><strong>Any confounders? </strong>Any factors that influence how many channels a shopper uses AND how much they spend per transaction?</p><p><strong><em>Well, how about the number of times the shopper has shopped with you in the past year?</em></strong></p><ul><li><em>In the extreme case, if they have shopped with you just once, there’s no way they can be in the multi-channel group.</em> More generally, the more times they have shopped with you in the past year, the more likely that they used more than one channel.</li><li>The more times they have shopped with you, it is more probable that they like your products and are more familiar with your product catalog, and therefore more likely to spend more per transaction.</li></ul><p>Let’s go after this confounder.</p><p>3. We can <strong>control</strong> for this confounder by splitting the data using the distinct values of the confounder (as the splitting variable) and calculating the average spend per transaction for each bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRIEJ2fO2qR6_l3df9HGTg.png" /></figure><p>There are a few things to note in this table:</p><ul><li>We have excluded those customers who purchased exactly <em>once</em> in the past year since even the notion of multi-channel isn’t applicable to them.</li><li>We have stratified using three buckets: 2 purchases, 3–5 purchases and more than 5 purchases. This is a bit of a balancing act - if we stratify into too many buckets, we may not have enough data in some buckets. If we stratify into too few, we will be mixing apples and oranges in the same bucket. My approach is to start the analysis with a handful of buckets and then see how the results of the analysis change if you add more buckets.</li><li>The overall numbers ($33.80 and $44.10) are just weighted averages of the numbers below. This is just a check to make sure we haven’t made a mistake when we split the data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6Msko0IthI4ijtscnF8fQ.png" /></figure><ul><li>Now we come to the heart of the analysis. We look at each <em>stratum</em> (i.e., each confounder bucket) and calculate how the spend number changes as you go from single to multi-channel customers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJtPgTqoSeObEXow2s86iQ.png" /></figure><ul><li>Note that all these changes are in the 1–3% range, in contrast to that big 30% number we started with. This is an indication that confounding is at work and the 30% number is suspect.</li></ul><p>Finally, as we learned in <a href="https://towardsdatascience.com/how-to-use-causal-inference-in-day-to-day-analytical-work-part-1-of-2-b5efbdbf8ab0">Part 1</a>, we “<em>de-confound” </em>by calculating <strong><em>adjusted</em></strong> overall numbers. <em>The adjustment is done by weighting the stratum-level numbers with the % of customers in the entire dataset that are in each stratum</em>.</p><p>We calculate the <em>adjusted</em> average spend/transaction for single-channel customers as follows ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEE0KGeSILImjexhxYiBHQ.png" /></figure><p>… and similarly for multi-channel customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RB4reEUkz79Lv36bMhdrSw.png" /></figure><p>As was emphasized in <a href="https://towardsdatascience.com/how-to-use-causal-inference-in-day-to-day-analytical-work-part-1-of-2-b5efbdbf8ab0">Part 1</a>, <em>it is vital that the same weights — the % of customers in the entire dataset that are in each stratum — are used to adjust both sets of numbers</em>.</p><p>OK, what do we get?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8tq6fjDsOleRAdTfaxSpQ.png" /></figure><p>The story has changed drastically!</p><p>The 30% difference that originally got us excited has shrunk to 2%.</p><p>Among those customers with two purchases in the past year, multi-channel customers spent just 1.5% more than single-channel customers! And among customers with more than five purchases, multi-channel customers spent only a modest 2.8% more than single-channel customers!</p><p>Given this dramatic discrepancy between the original 30% number and the adjusted (de-confounded) number of 2%, it is unlikely that there is a significant causal effect due to multiple channels. Do <strong>not</strong> take this to the CEO :-)</p><p>I used just one confounder above to make it easy to explain. But you can use more if you like. For example, you may suspect that shoppers who live in rural areas far from one of your bricks-and-mortar stores may buy exclusively online (and therefore be part of the single-channel group). Rural shoppers may have a different spending profile than others so this may affect the spend metric as well.</p><p>Assuming you have the data, you can extend the table above as follows, and like we did above, compare the adjusted number to the overall number:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w25DxZs2HsblHm8K0X0mIQ.png" /></figure><p>At this point, you may be wondering: “What if I have more than one or two cofounders? What if I have half a dozen? Stratification will get pretty unwieldy, won’t it?”</p><p>Good question. Yes, stratification <em>will</em> get messy. You will need to use multivariate methods like <a href="https://en.wikipedia.org/wiki/Linear_regression">Linear Regression</a> or <a href="https://en.wikipedia.org/wiki/Logistic_regression">Logistic Regression</a> to get the job done. You can follow-up on these references (<a href="https://linkinghub.elsevier.com/retrieve/pii/S0085253815529748">article</a>, <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4017459/">article</a>, <a href="https://oem.bmj.com/content/62/7/500">article</a>) to learn more but here’s a quick example from my experience.</p><p>Let’s say you work for a retailer and are considering the purchase of a price optimization system. How would you understand/quantify the impact of the use of the system on revenues?</p><p>In an ideal world, you would do an A/B test where a random 50% of products would be priced using the price optimization system and the other 50% would be priced with your current approach. You would run this test for a while and then compare the two groups on revenue etc.</p><p>Unfortunately, due to certain organizational reasons, this may not be possible (e.g., perhaps you can’t <em>force</em> your merchandising team to use the system for certain products but not others). But what you <em>can</em> do is to make the system available to <em>all</em> the end-users to use <em>if they wanted to </em>i.e. you can allow end-users to <em>self-select</em> which products they want to price with the new system.</p><p>This self-selection clearly implies a situation with non-random assignment and you can’t simply compare the average revenue from products priced using the new system vs the average revenue from products priced using your current approach.</p><p>So, what’s the best way to analyze the resulting data to evaluate the system’s revenue impact?</p><p>Let’s apply the checklist. What are some potential confounders?</p><ul><li><strong>The category of the product</strong>. Different product categories may have vastly different revenues and if the end-users in charge of pricing for those categories are drawn to/repulsed by the new system in certain ways (e.g., those responsible for fashion-forward product categories may be more likely to believe that no optimization system can beat their gut instinct), it will certainly confound the results.</li><li><strong>Rate-of-sale of the product</strong>. Maybe your team views the new system as risky and unproven and therefore will use it only for products that don’t sell much; if this happens, the new system’s performance will look worse than it actually was.</li><li>… and so on.</li></ul><p>Using these sorts of considerations, several potential confounders can be identified. But since there are too many confounders to do stratification, we can use regression instead.</p><p>We assemble a dataset like this, one row for each product:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*UlRM7q_kwkcxhmsw_vjOoQ.png" /></figure><p>For illustration, I have included columns for Product Category, the Rate-of-Sale of the product, its Price Tier, its Revenue from the same period in the prior year etc. as potential confounders.<em> In practice, you will have to use your domain knowledge and business judgment to come up with this list.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qfpM-2g700g5-3IsN7QuNg.png" /></figure><p>I also have a column (“System Use Indicator”) that is a 0–1 variable indicating if the new price optimization system was used to price that product or not. Finally, I have a column that shows the revenue for each product during the test period.</p><p>With this dataset, we can fit a regression model* to this data with “Test-period Revenue” as the dependent variable and all the other columns as independent variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fa5bTdDti1Gtjlz-Dw0pJg.png" /></figure><p>Now, finding the causal effect of using the price optimization system vs the current approach is as simple as reading a number off the regression output.</p><blockquote><em>The coefficient of the “System Use Indicator” dummy variable gives you the incremental </em>causal impact <em>of using the optimization system on Test-period Revenue, controlling for all the other variables.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zy3zeS3ZklaNtSwUqF72sQ.png" /></figure><p>This approach is widely used: when a causal effect is desired, analysts will identify confounders and routinely <em>throw them into a regression</em> along with the treatment and outcome variables, and pluck out the coefficient of the treatment variable as the causal treatment effect. When you read an article in the newspaper that “X is associated with a higher risk of Y, <em>after controlling for</em> age, gender, BMI, blood pressure and level of physical activity”, this is what’s going on.</p><p>This approach should definitely be in your data science toolbox but please remember that it depends on some very critical assumptions, including:</p><ul><li>All confounders have been included in the model i.e., there are no other confounders (this is probably the most important assumption)</li><li>The effect of the variables on the outcome is linear</li></ul><p>(further reading: <a href="https://oem.bmj.com/content/62/7/500">pros and cons to using stratification vs regression</a>)</p><p>(* The way the table is laid out implies a linear <em>additive</em> model. I did so for ease of explanation but a <a href="http://www-ist.massey.ac.nz/dstirlin/CAST/customCAST/Hmultiplicative/multiplicative1.html"><em>multiplicative</em> model </a>may be better for this problem if you had to do it for real: express Test-period Revenue as the product of all the factors, take logarithms to make it linear in the parameters, then fit the resulting linear regression model)</p><p>This discussion barely scratches the surface of a vast literature on how to make good inferences from observational data. There’s plenty of <a href="https://medium.com/causal-data-science/causal-data-science-721ed63a4027">good material online</a> and many <a href="https://causalinference.gitlab.io/books/">books</a> and <a href="https://causalinference.gitlab.io/courses/">courses</a>. If you are just starting out on your learning journey, you are in for a treat :-).</p><p>I want to conclude by reiterating an important caveat from <a href="https://towardsdatascience.com/how-to-use-causal-inference-in-day-to-day-analytical-work-part-1-of-2-b5efbdbf8ab0">Part 1</a>.</p><p>Causal inference methods applied to observational data aren’t fool-proof. They rest on a number of important assumptions (e.g., no important confounders are missing in the data) and there’s no guarantee that what you have found is a true causal effect; judgement and care is needed to assess what the numbers mean.</p><p>Nevertheless, thinking of potential confounders and how you might control for them increases your <strong><em>causal IQ</em></strong> and will keep you from jumping to the wrong conclusion often enough that you should make it a habit.</p><p>(If you found this article helpful, you may find <a href="https://rama100.github.io/lecture-notes/">these</a> of interest)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1824e7024cd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-use-causal-inference-in-day-to-day-analytical-work-part-2-of-2-1824e7024cd2">How to Use Causal Inference in Day-to-Day Analytical Work— Part 2 of 2</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[Data Scientists, Ask Yourself Often: So What?]]></title>
            <link>https://medium.com/data-science/data-scientists-ask-yourself-often-so-what-69a7ec5895be?source=rss-28748480e8bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/69a7ec5895be</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Rama Ramakrishnan]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 15:43:47 GMT</pubDate>
            <atom:updated>2020-06-08T19:06:44.992Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbV6VeCRFwxZRN2pbiPAgA.jpeg" /></figure><p>I used to work at a global management consulting firm many years ago. As a new associate, when I presented the results of my work, I’d often be stopped in my tracks with, “That is interesting. But what is the <strong><em>so what</em></strong> here?”</p><p>“So what” was shorthand for several related things.</p><ul><li>Is there anything <em>actionable</em> here?</li><li>What should we tell the client to do <em>differently</em> because of this?</li><li>If we continue down this path, does it get us closer to our ultimate destination?</li></ul><p>New associates quickly developed the habit of considering the so-what of their findings before presenting anything. While painful and humbling at first, this turned out to be a very useful habit. It helped us avoid “boiling the ocean”, perform better under time pressure, and made us more productive.</p><p>I think data scientists would benefit from cultivating this mindset.</p><p>Data science work involves activities that are rife with opportunities to get distracted. Getting the data, <a href="https://towardsdatascience.com/i-have-data-i-need-insights-where-do-i-start-7ddc935ab365">exploring the data</a>, <a href="https://rama100.github.io/lecture-notes/x2y.nb.html">understanding relationships between variables</a>, formulating a problem, <a href="https://towardsdatascience.com/first-create-a-common-sense-baseline-e66dbf8a8a47">creating a common-sense baseline</a>, building models, tuning hyper-parameters and so on.</p><p>Good data scientists tend to be intellectually curious which, of course, is a fantastic thing. But it also means that they are likely to catch the glimmer of a shiny object off to the side of the road and follow it into a rabbit hole. While this is almost always intellectually fun, sometimes it will be useful, sometimes not.</p><p>To make sure you are spending your time wisely, you should periodically pause and ask yourself, “What’s the <strong><em>so what</em></strong> here?”.</p><p>Is there something concrete and actionable I can get out of this? Does it get me closer to solving the ultimate problem I am working on?</p><p>Your answer to the ‘so what’ question doesn’t have to be detailed or exact. It just has to pass a gut check that there’s at least a conceptual path from your current obsession to something useful. If you can’t find a path, you should re-assess if you should switch your focus to something else.</p><p>This habit is particularly useful when you start to work on a new problem, especially one posed by someone else and presented to you. As you try to understand and crystallize what exactly needs to be solved, you may come to realize that the problem as defined isn’t actually worth solving because something <em>else</em> is the bottleneck and that needs to be solved first.</p><p>Having a so-what mindset gets you to clarity faster and, as a bonus, also builds your reputation in the organization as a pragmatic, clear-thinking data scientist.</p><p>All this said, an important caveat.</p><p><strong>Ask ‘so what’ in moderation</strong>. I am not recommending you become a so-what asking humorless robot.</p><p>Going where your curiosity takes you can be useful — you may serendipitously stumble on something valuable in your random explorations. <em>More importantly, it is clearly necessary for one’s happiness.</em> If I couldn’t randomly check stuff out and ‘aimlessly’ play with ideas, I will go crazy.</p><p>So explore, follow your curiosity, have fun. But have a background process running in your brain that periodically pops up and asks “what’s the <strong><em>so what</em></strong> here?”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69a7ec5895be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/data-scientists-ask-yourself-often-so-what-69a7ec5895be">Data Scientists, Ask Yourself Often: So What?</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>