** Business analytics practitioners are frequently called upon to improve commercial outcomes by modelling the impact of operational business decisions. One example could be the prioritisation of a certain group of customers for a marketing intervention, such as a retention offer.
** This is a relatively immature area where there are as yet no standard references and only a few non-research texts (e.g. cite:michel2019). As the basic techniques are not well established, methodological errors remain common.
** In this presentation we will review some results on offline contextual bandits[fn:: Offline contextual bandits setting generalises uplift modelling from marketing analytics.] -- a robust framework for optimisation of operational decisions and estimation of expected benefits.
The need for incrementality
:PROPERTIES:
:BEAMER_opt: allowframebreaks,label=
:END:
** While standard supervised learning cite:hastie2009 is well suited for pure /prediction/, an equally common task in business analytics is to assess the incremental or net effect of a decision, sometimes also called an /intervention/ or /treatment/.
** The net effect means that outcomes that we are measuring can occur with and without the intervention and we are interested in /change/ under the intervention and not the absolute value.
The need for incrementality II
** Some examples where incrementality is important:
\footnotesize
displaying a product ad on a website may have some customers interact with it who would have purchased the product anyway,
sending a direct marketing communication advertising a service may influence some recipients but many might already know about it through other channels,
a churn prevention campaign may cause some customers to leave by reminding them to look at other options in the market,
a novel medical treatments is administered to a group of patients but while beneficial it is not an improvement relative to the current best protocol,
crop yield in an experiment to assess a new fertiliser regiment is affected by local microclimate,
pre-emptive maintenance procedures carried out to avoid plant malfunctioning do not reduce frequency of failure for particular models of equipment.
Randomised controlled trials
** Randomised controlled experiments have emerged as the gold standard for answering questions of this type across life sciences and more recently have become adopted at scale by internet platform businesses cite:kohavi2020.
** The idea is to measure the /difference/ in outcomes between two statistically identical populations constructed via randomisation where one, the so called , is subjected to the intervention being assessed and the other, the receives no or inert intervention.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
** The practice is far from universal -- when it comes to sales and marketing, for example, while there is a consensus that systematic measurement against control groups represents best practice, it is very common for a sale to be ``claimed'' by multiple campaigns and channels. In many situations any ad that has touched the customer up to several months prior to purchase receives complete or partial credit.
Propensity modelling
** Even when control groups are used, it is often limited to assessment of average treatment effects after the fact, with targeting and personalisation done through so called propensity models that /disregard incrementality/ cite:devriendt2021.
** The typical approach to targeting with the aid of a propensity model can look like this:
\footnotesize
identify members of the study population that have had some desired outcome r occur during a fixed time window,
construct a “propensity model” that gives the probability or expected value of the positive outcome for each member, E(r∣x), where x are some known attributes of individual population members;
use this model to choose a target group of with low expected values of r, possibly holding out a control group for post-campaign incrementality assessment;
subject the target group to the intervention a designed to improve the desired outcome (excluding the control group, if any, which we denote a∅),
possibly assess the incremental effect of treatment by comparing the achieved response to that of the control group.
Response modelling and expected lift
** In a variation of the procedure called response modelling the analysis in step 2 is restricted to participants of an initial test campaign, yielding E(r∣x,a). the main campaign is then targeted at the subset of population with /highest/ expected value of r.
** While either approach can be reasonable in certain specific cases, it is fundamental that if we wish to achieve the largest possible improvement in the outcome, the quantity used for targeting must be precisely the expected improvement in the outcome, also called lift:
[
\text{Lift} = \mathbb{E}(r,|,\mathbf{x},a) - \mathbb{E}(r,|,\mathbf{x},a_\emptyset),
]
It is the difference between expected outcome under the intervention a and null intervention or control a∅ for individual population members.
Targeting interventions based on expected lift
** In the rest of the presentation we will focus on modeling variations in lift across population, also known as heterogeneity of treatment effect[fn:: Traditional RCTs deal with average treatment effects only.].
** The methodology has been reinvented several times -- in experimental medicine as dynamic treatment regimes cite:chakraborty2014, in computer science as offline contextual bandits cite:agarwal2017 and in marketing analytics as uplift modelling cite:radcliffe2007.
** As work outside of computer science has centered on the case of a single intervention and can be difficult to generalise, we adopt the ``offline contextual bandit'' set up and associated terminology.
Offline contextual bandits -- setup
** The basic setting is that the modeller has access to a dataset of n observations collected through a randomised pilot study or a test campaign and consisting of the following for the i-th observation (also illustrated in Figure 1):
\footnotesize
individual attributes or /decision contexts/ xi∈Rm, which depending on application can be days since the last purchase, comorbidities, crop variety, service hours of equipment etc;
intervention or /action/ ai∈{a(1),…,a(k)} taken for the i-th interaction, such as type of ad shown, dosage administered, equipment diagnostics protocol carried out and so on;
value of outcome ri(ai) if the entity intervened upon by action ai, also known as /reward/, this can be total revenue from new sales to a customer over the next two weeks, condition of a patient at a follow up examination, plant uptime etc;
the /logging distribution/ pi -- where pi(ai) is the probability with which action was chosen in this context during the randomised pilot study. We assume that . Often the logging distribution is uniform, that is .
** This dataset can then be represented as a collection of tuples {(xi,ai,ri,pi)}i=1n.
Offline contextual bandits -- data collection
#+ATTR_LATEX: :height 5.5cm
#+ATTR_LATEX: :center t
#+CAPTION: \footnotesize Conceptual representation of the data collected during the randomised pilot study. For i-th entity ci we record the assigned action (treatment/no treatment in this case); the reward ri is calculated as the sum of initial costs and any positive outcomes during the post-intervention measurement window. Just before the intervention we capture a snapshot of entity's attributes and history, this becomes decision context xi.
#+results:
file:personalisation_lifecycle.png
Key tasks -- policy evaluation and learning
** A decision rule or /policy/ is a function π:Rm→A mapping contexts to actions.
** There are two main tasks:
estimation of the value of a given decision rule and,
finding the best such rule.
** In computer science literature these are referred to as /off-policy policy evaluation/ and /off-policy learning/ respectively.
Decision rule evaluation - IPS
** First we will look at the estimation of the value of a decision rule which is just the expected value of rewards if the rule is followed and which we can write as:
[
V(\pi)=\frac{1}{n}\sum_{i=1}^n \mathbb{E}_{a, r}\big[r_i\big(\pi(\mathbf{x}_i)\big)\big].
]
** If we have data that was acquired in accordance to π, the estimation of is a simple matter of computing n1∑i=1nri(ai), but what if we only have data sampled randomly?
** Consider just the reward for the i-th observation -- we logged the reward for action ai but now want to find reward for action a(j). We can do this using the /inverse propensity weighted estimator/ cite:dudik2014 or inverse propensity scoring (IPS):
\begin{align}\label{r_ips}
\hat{r}_i\big(a^{(j)}\big) = r_i\big(a_i\big)\frac{\mathbb{I}\big(a_i=a^{(j)}\big)}{p_i(a_i)}.
\end{align}
Decision rule evaluation - IPS is unbiased
** This may seem an odd calculation: ri(ai)pi(ai)I(ai=a(j)) is zero unless a(j)=ai, but if we were to keep xi fixed and repeatedly resampled ai and ri we would get the right result on average, which means that the estimator is /unbiased/:
\vspace{-1cm}}
\begin{align*}
\mathbb{E}{r,a}\Big[\hat{r}i\big(a^{(j)}\big)\Big]& = \mathbb{E}{r,a} \bigg[r_i(a_i)\frac{\mathbb{I}\big(a_i=a^{(j)}\big)}{p_i(a_i)}\bigg]\
&= \mathbb{E}{a}\bigg[\mathbb{E}{r}\big[r_i(a_i)]\frac{\mathbb{I}\big(a_i=a^{(j)}\big)}{p_i(a_i)}\bigg]\
&= \mathbb{E}{r}\Big[r_i\big(a^{(j)}\big)\Big]\frac{p_i\big(a^{(j)}\big)}{p_i\big(a^{(j)}\big)} = \mathbb{E}{r}\Big[r_i\big(a^{(j)}\big)\Big].
\end{align*}
\vspace{-0.5cm}}
** We use this result to obtain an estimate of the value of an arbitrary policy π over the entire dataset:
[
\hat{V}(\pi)=\frac{1}{n}\sum{i=1}^n\hat{r}_i\big(\pi(\mathbf{x}i)\big) = \frac{1}{n}\sum{i=1}^n r_i(a_i)\frac{\mathbb{I}\big(a_i=\pi(\mathbf{x}_i)\big)}{p_i(a_i)}.
]
Decision rule evaluation - IPS example
#+ATTR_LATEX: :height 5.5cm
#+ATTR_LATEX: :center t
#+CAPTION: \footnotesize Example calculation of r^i(π(xi)) for a retail checkout discount voucher offer . Each product has different price and cost of goods . Flag indicates whether purchase has been completed. Reward is given by ).
#+results:
| | | | | | | |
|-------+-------+---------------------+-------+-------+-------+-----------------------------------------------|
| 250 | -20 | 0 | 0.25 | 1 | 200 | --- |
| 375 | 0 | 0 | 0.50 | 0 | 310 | |
| 500 | -10 | -10 | 0.25 | 1 | 370 | |
| 150 | -10 | -10 | 0.25 | 1 | 120 | |
| 230 | 0 | -20 | 0.5 | 1 | 200 |--- |
Decision rule evaluation - IPS is unbiased II
** The estimator V^ is also unbiased -- if we hold {xi}i=1 constant and average over random draws of we get:
[
\mathbb{E}{a,r}\Big[ \frac{1}{n}\sum_{i=1}^n\hat{r}{r}\big[\hat{r}_i\big(\pi(\mathbf{x}_i)\big) \big].
]
** Under fairly mild conditions the variance of is no greater than the variance of the estimate of the average reward for the least frequent action under the logging policy .
Decision rule evaluation - IPS variance
** To see this we compute the variance of V^(π). First we look at the i-th observation again:
** Variance of V^(π) turns out to be linear in npi1 and therefore scales with the size of the smallest group in the test campaign.
Practical consequences of IPS
** This result means one can collect randomised data and repeatedly reuse it to evaluate new decision rules without the need for testing them individually, giving in an exponential efficiency gain over the naive protocol where the control group is used only for post-campaign incrementality assessment.
** It is perhaps not an exaggeration to remark that large scale deployment of ``off-policy policy evaluation'' could be one of the more impressive recent practical advances in applied statistics.
Finding the best decision rule
** Let's say we want to find the best decision rule π⋆=πargmaxV(π). A straightforward way to do this is to use the IPS estimator V^ as the surrogate for V:
\begin{align}\label{optim}
\hat{\pi}=\underset{\pi}{\operatorname{argmax}}\ \frac{1}{n}\sum_{i=1}^n r_i(a_i)\frac{\mathbb{I}\big(a_i=\pi(\mathbf{x}i)\big)}{p_i(a_i)}.
\end{align}
This is equivalent to a cost sensitive classification problem where ai is the label and class costs are given by:
[
c_i^{(j)}=\begin{cases}
-\frac{r_i(a_i)}{p_i(a_i)}, & \text{if ai=a}\
0, & \text{otherwise}
\end{cases}
]
and the optimisation objective (\ref{optim}) is re-written as follows:
[
\hat{\pi}=\underset{\pi}{\operatorname{argmin}}\ \frac{1}{n}\sum{i=1}^n\sum_{j=1}^k \mathbb{I}\big(\pi(\mathbf{x}_i)=a^{(j)}\big)c_i^{(j)}.
]
Finding the best decision rule -- rewards regression
** While there are several software packages that support cost sensitive classification directly, one can use a popular transformation from cost-sensitive classification to regression cite:tu2010 for maximum flexibility.
** This is done by replacing every row in the classification dataset with k rows using cost as the label:
[
\underbrace{\begin{bmatrix}
a_i&\mathbf{x}i\
\end{bmatrix}
}{\text{original}}
\quad \longrightarrow \quad
\underbrace{\begin{bmatrix}
-c_i^{(1)} & \mathbf{x}_i^T & \mathbf{x}_i^T & \mathbf{0} & \ldots & \mathbf{0}\
-c_i^{(2)} & \mathbf{x}_i^T& \mathbf{0} & \mathbf{x}_i^T & \ldots & \mathbf{0}\
\vdots & \vdots & \vdots &\vdots &\ddots &\vdots \
-c_i^{(k)} & \mathbf{x}_i^T & \mathbf{0} & \mathbf{0} & \ldots & \mathbf{x}i^T\
\end{bmatrix}
}{\text{transformed}}.
]
Data shared lasso model
** With this representation in place we can fit a regression model with ℓ1-norm regularisation:
[
\underset{\mathbf{w}_0, \mathbf{w}1 \ldots \mathbf{w}k}{\operatorname{minimise}} \quad \sum{i=1}^n\sum{j=1}^k \Big(c_i^{(j)}-\mathbf{x}_i^T(\mathbf{w}_0+\mathbf{w}_j)\Big)^2+\lambda\Big(|\mathbf{w}|1 + \eta\sum{j=1}^{k}|\mathbf{w}_j|_1 \Big)
]
** This is an instance of so called data shared lasso'' cite:gross2016, where we penalise coefficients $\mathbf{w}_i$ that deviate from $\mathbf{0}$ resulting only in significant deviations from average response being kept. ** Data shared lasso'' is implemented via the standard lasso following the data transformation described above and parameter vectors concatenated.
Estimated decision rule
** If w^j(λ) is the solution to the above problem for a given value of λ then the decision rule π^(xi,λ) is:
\begin{align}\label{model}
\hat{\pi}(\mathbf{x}i,\lambda) = \underset{a \in \mathcal{A}}{\operatorname{argmax}}\ \sum{j=1}^k \mathbb{I}\big(a=a^{(j)}\big) \mathbf{x}_i^T\hat{\mathbf{w}}_j(\lambda),
\end{align}
** which for the i-th observation is just the action a(j) with the largest value of xiTw^j(λ).
Optimal decision rule validation
** To chose the correct value of λ and get an unbiased estimate of V^(π^) we turn to the /hold out set/ -- a random subset of the original data that has not been used for model fitting.
** Recall that we are primarily interested in the improvement afforded by deploying π^ over some default action or control a∅. The default action can be not contacting a customer, displaying a blank image in an ad slot etc. In the following we assume that a∅ is one of k that have been logged during the pilot study.
** Expected improvement over the default action, or lift, associated with the decision rule π^ for the i-th observation is given by E[li(π(xi))]=E[ri(π
** For the entire dataset the average lift is V(π)−V(π∅) where π∅ is the decision rule that always returns the default action.
IPS and model based estimates of lift
** The IPS estimate l^ will be analogous to (\ref{r_ips}):
[
\hat{l}_i\big(a^{(j)}\big)=r_i(a_i)\frac{\mathbb{I}\big(a_i=a^{(j)}\big)- \mathbb{I}(a_i=a^\emptyset\big)}{p_i(a_i)},
]
but we can also use the model (\ref{model}) to estimate li. Denote model based estimate as l~:
[
\tilde{l}_i\big(a^{(j)},\lambda\big) = \mathbf{x}_i^T\big(\hat{\mathbf{w}}j(\lambda) - \hat{\mathbf{w}}{\emptyset}(\lambda)\big).
]
Generalised cumulative lift chart
** We can now examine the relationship between l~ and l^ graphically. A common diagnostic is the so called /qini plot/ cite:surry2011, first introduced in the context of uplift modelling and which we extend to the arbitrary number of actions. It is defined parametrically for l~min≤t≤l~max as:
** Here the x axis corresponds to the percentage of the population with model based estimate of lift above a threshold and y axis shows the IPS estimate of average lift if only that subset is targeted by π^(λ). These plots can be used to choose both λ and the model lift cutoff point t∗ (contexts with l~i(π(xi),λ are assigned to the default action).
Simulation study
#+ATTR_LATEX: :height 4.6cm
#+ATTR_LATEX: :center t
#+CAPTION: \footnotesize Out of sample IPS generalised lift curves for a simulated dataset with ∣A∣=5 , m=5, uniform logging policy, n=100,000 and an equal split between training and test. Red dot represents λ∗ and cut-off t∗ chosen. /Left:/ Rewards for all actions have the same expected values. /Right:/ Harder case -- expected rewards for the default action are increase by 1.
#+results:
file:qini_results.png
Beware of biased estimators -- model based rewards
** There is a number of commercial software offerings that use V~(π^)= computed either in or out of sample to estimate and report lift.
** These estimates are usually biased out of sample and are essentially guaranteed to exhibit significant positive bias in sample and should not be used, see cite:semenovich2019 for another example.
** Similar challenges are encountered if using IPS estimates in sample but the practice appears uncommon.
Simulation study -- biased estimation
#+ATTR_LATEX: :height 4.6cm
#+ATTR_LATEX: :center nil
#+CAPTION: \footnotesize /Left:/ Out of sample IPS generalised lift curves for a problem with ∣A∣=5 , m=20, uniform logging policy and n=10,000. /Right:/ Same decision rule family ) but evaluated using the model based reward estimate out of sample. Results are both over-optimistic /and/ yield a suboptimal choice of and .
file:qini_biased.png
Conclusion
** We have provided a simple introduction to the uplift modelling / contextual bandit setting and summarised some basic results, including the remarkable ability of the IPS estimator to efficiently reuse randomised historical data.
** A data-efficient modelling approach amenable to the use of standard lasso packages and a novel validation diagnostic were also described together with a simulation study demonstrating the importance of unbiased estimation.
Use the background provided to devise a solution to the problem below:
Data Science - Price Optimization Task You are provided with synthetic data from a pricing experiment conducted on embedded travel insurance within an OTA (Online Travel Agency) funnel for flights. Each time a customer proceeds to checkout a flight, an insurance quote is generated. The quotes dataset includes flight attributes and pricing details for each quote as described below: row_id country_of_origin country_of_destination lead_time trip_duration ticket_price number_of_passengers return_trip base_retail_premium split p conversion retail_premium modifier 1 Canada India 133 17 1572.96 3 TRUE 157.30 tr 0.2 1 173.03 10 2 Spain Brazil 62 16 1751.35 1 TRUE 175.14 tr 0.2 0 192.65 10 3 USA Japan 4 7 1961.71 4 FALSE 196.17 tr 0.2 0 235.41 20 4 USA Australia 66 27 719.63 3 TRUE 71.96 tr 0.2 0 64.77 -10 5 France Australia 175 6 1932.60 1 FALSE 193.26 tr 0.2 0 173.93 -10 row_id column is a unique quote identifier. country_of_origin column indicates country from which journey starts. country_of_destination column indicates country where journey ends. lead_time column represents number of days between booking and departure. trip_duration column shows duration of trip in days. ticket_price column lists price of flight ticket. number_of_passengers column shows how many passengers are included in quote. return_trip column is a boolean indicating whether trip is a round trip. base_retail_premium column shows base price of travel insurance before any modifications. split column indicates whether data is part of training set ('tr') or test set ('te'). Note that the outcomes for the test set are not available - it is here so that your submission can be evaluated. p column represents the sizes of experiment groups for different modifiers. In this case they are equal at 20% of quotes. The modifier column represents a random modification to the base price based on a hashed customer ID. The retail_premium is calculated as base_retail_premium * (1 + modifier/100). If the insurance policy is purchased, the conversion field is set to 1, and the total retail premium received is retail_premium * conversion. Your task is to analyze the "training" data and construct a pricing rule that maps flight attributes to modifiers. This rule should aim to maximize the average converted premium per quote when deployed. Once you have a candidate rule, we will evaluate it on a hold out sample. To do this you should assign your proposed modifier to each row where split equals "te" (the test data). The submission will be evaluated by how much of total available lift over the default submission of always assigning modifier 0 has been captured: The scoring formula is given by: Score = 𝑉 ( 𝜋 optimal ) − 𝑉 ( 𝜋 proposed ) 𝑉 ( 𝜋 proposed ) − 𝑉 ( 𝜋 base ) Score= V(π proposed )−V(π base ) V(π optimal )−V(π proposed ) where: V(πoptimal) is the value of the optimal policy, representing the maximum possible value that could be achieved (remember this is a simulation). V(πproposed) is the value of the proposed policy, representing the value achieved by the policy you are testing. V(πbase) is the value of the baseline policy, where no modifications are made to the pricing. The score measures the relative improvement of the proposed policy over the baseline, normalized by the maximum possible improvement (from baseline to optimal). Output your results in a CSV file named submission.csv with the following format: row_id proposed_modifier 499386 0 499387 0 499388 0 499389 -20 499390 -20 499391 -20 499392 -20 The CSV file should only include rows from the test split. Outline how you will model this task - what will be you dependent variable, what modelling framework is approriate (list at list 3). Give formulas for the optimisation and validation objectives.
Make sure to list your proposed solution step by step with formulas
To model this price optimization task, we can follow these steps:
Dependent variable: The dependent variable is the modifier column, which represents the random modification to the base price based on a hashed customer ID. Our goal is to predict the optimal modifier value for each quote based on flight attributes.
Modeling framework: We can use a regression model to predict the optimal modifier value. Since the target variable is continuous, we can use linear regression or gradient boosting regression as our modeling framework. We will use the training data to train the model and then evaluate its performance on the test data.
Optimization objective: The optimization objective is to maximize the average converted premium per quote when deployed. We can define the optimization objective as follows:
where l~i(π^(xi)) is the estimated lift for the i-th observation using the model-based estimate, π^(xi) is the predicted action for the i-th observation, and xi is the feature vector for the i-th observation.
Validation objective: To evaluate the performance of our model, we can use the out-of-sample IPS generalised lift curve, as described in the background. We can compute the average lift over the test set and compare it to the baseline of always assigning modifier 0. The validation objective can be defined as follows:
where ntest is the number of observations in the test set, and and are the estimated lift for the -th observation using the proposed policy and the baseline policy, respectively.
Model evaluation: Once the model is trained, we can evaluate its performance on the test set by computing the validation objective. We can also visualize the out-of-sample IPS generalised lift curve to gain insights into the model's performance across different quantiles of the population.
Submission: Finally, we can create a CSV file named submission.csv with the row_id and proposed_modifier columns for the test set, where proposed_modifier is the predicted optimal modifier value for each quote based on the trained model.