Extracted main text — title through conclusion, appendix excluded. This is what our citation measures are computed over, published so the extraction can be checked by eye.
76,000 characters · 19 sections · 66 citation commands
Estimation Considerations in Contextual Bandits
Contextual bandits seek to learn a personalized treatment assignment policy in the presence of treatment effects that vary with observed contextual features. In such settings, there is a need to balance the exploration of treatments\footnote{A treatment is also referred to as an arm in the literature. In this paper, we use the two terms interchangeably.} for which there is limited knowledge in order to improve performance in the future against the exploitation of existing knowledge in order to attain better performance in the present (see bubeck-survey for a survey). Since large amounts of data can be required to learn how the benefits of alternative treatments vary with individual characteristics, contextual bandits can play an important role in making experimentation and learning more efficient. Several successful contextual bandit designs have been proposed auer-linrel, li-linucb, agrawal-lints, agarwal-ilovetoconbandits,bastani2015online. The existing literature has provided regret bounds (e.g., the general bounds of russo-vanroy, the bounds of rigollet-nonparamtheory, perchet-nonparamtheory, slivkins-nonparamtheory in the case of non-parametric function of arm rewards), has demonstrated successful applications (e.g., news article recommendations li-linucb or mobile health lei-mhealth), and has proposed system designs to apply these algorithms in practice agarwal-debt.
Contextual bandits are poised to play an important role in a wide range of applications: content recommendation in web-services, where the learner wants to personalize recommendations (arm) to the profile of a user (context) to maximize engagement (reward); online education platforms, where the learner wants to select a teaching method (arm) based on the characteristics of a student (context) in order to maximize the student's scores (reward); and survey experiments, where the learner wants to learn what information or persuasion (arm) influences the responses (reward) of subjects as a function of their demographics, political beliefs, or other characteristics (context).
In the contextual setting, one does not expect to see many future observations with the same context as the current observation, and so the value of learning from pulling an arm for this context accrues when that observation is used to estimate the outcome from this arm for a different context in the future. Therefore, the performance of contextual bandit algorithms can be sensitive to the estimation method of the outcome model or the exploration method used. In the initial phases of learning when samples are small, biases are likely to arise in estimating the outcome model using data from previous non-uniform assignments of contexts to arms. The bias issue is aggravated in the case of a mismatch between the generative model and the functional form used for estimation of the outcome model, or similarly, when the heterogeneity in treatment effects is too complex to estimate well with small datasets. In that case methods that proceed under the assumption that the functional form for the outcome model is correct may be overly optimistic about the extent of the learning so far, and emphasize exploitation over exploration. Another case where biases can arise occurs when training observations from certain regions of the context space are scarce (e.g., prejudice in training data if a non-representative set of users arrives in initial batches of data). These problems are common in real-world settings, such as in survey experiments in the domain of social sciences or in applications to health, recommender systems, or education. For example, early adopters of an online course may have different characteristics than later adopters.
We develop parametric and non-parametric contextual bandits that integrate balancing methods from the causal inference literature imbens-ci in their estimation to make it less prone to the aforementioned sources of bias. Our methods aim to balance covariates between treatment groups and achieve contextual bandit designs which are less prone to problems of bias. The balancing will lead to lower estimated precision in the reward functions, and thus will emphasize exploration longer than the conventional linear TS and UCB algorithms, leading to more robust estimates. Balancing can take various forms, ranging from the well-known inverse propensity score weighting to state of the art methods such as approximate residual balancing athey-arb or the method of kallus-offline. Moreover, balancing can be integrated in contextual bandits with a parametric model estimation such as ridge or LASSO) or non-parametric model estimation such as forests.
We further investigate the effect of balancing via inverse propensity weighting in the domain of linear contextual bandits, by comparing linear Thompson sampling (LinTS) agrawal-lints and linear upper confidence bound (LinUCB) li-linucb -- which have strong theoretical guarantees -- with our algorithms, balanced linear Thompson sampling (BLTS) and balanced linear upper confidence bound (BLUCB). Our main contribution here is to provide extensive and convincing empirical evidence for the effectiveness of BLTS and BLUCB (in comparison to LinTS and LinUCB) by considering the problem of multiclass classification with bandit feedback. Specifically, we transform a $K$-class classification task into a $K$-armed contextual bandit dudik-offline-1 and we use 300 public benchmark datasets for our evaluation. Additionally, we provide regret bounds for BLTS and BLUCB, which match the existing state-of-the-art regret bounds for LinTS and LinUCB. It is important to point out that, even though BLTS and LinTS share the same theoretical guarantee, BLTS outperforms LinTS empirically. Similarly, BLUCB has a strong empirical advantage over LinUCB. In bandits, this phenomenon is not uncommon. For instance, it is well-known that even though the existing UCB bounds are often tighter than those of Thompson sampling, Thompson sampling performs better in practice than UCB chapelle-tsucb. Consequently, we take the view that even though regret is a useful theoretical performance metric, it may not always provide clear guidance on which algorithm should be used in practice. We find that this is also the case for balanced linear contextual bandits, as in our evaluation BLTS has a strong empirical advantage over BLUCB. Overall, in this large-scale evaluation, BLTS outperforms LinUCB, BLUCB and LinTS. In our empirical evaluation, we also consider a synthetic example which simulates in the simplest possible way two issues of bias that often arise in practice; training data with non-representative contexts and model mis-specification. BLTS is much more effective in escaping these biases and, as in the evaluation on supervised learning datasets, it outperforms LinUCB, BLUCB and LinTS by a large margin.
To our knowledge, this is the first work to integrate balancing in the online contextual bandit setting, to perform a large-scale evaluation of it against direct estimation method baselines with theoretical guarantees and to provide a theoretical characterization of balanced contextual bandits that match the regret bound of their direct method counterparts. The balancing technique is well-known in machine learning, especially in domain adaptation and studies in learning-theoretic frameworks huang-ml,zadrozny-ml,cortes-ml. There is a number of recent works which approach contextual bandits through the framework of causality bareinboim-bandits, bareinboim-fusion, forney-fusion, lattimore-causalbandit. There is also a significant body of research that leverages balancing for offline evaluation and learning of contextual bandit or reinforcement learning policies from logged data strehl-offline, dudik-offline-1, li-offline-1, dudik-offline-2, li-offline-2, swaminathan-offline, jiang-offline, thomas-offline, athey-offline, kallus-offline, wang-offline, deshpande-offline, kallus2018policy, strehl2010learning,zhou2018offline. In the offline setting, the complexity of the historical assignment policy is taken as given, and thus the difficulty of the offline evaluation and learning of optimal policies is taken as given. Therefore, these results lie at the opposite end of the spectrum from our work, which focuses on the online setting, where the complexity of the assignment policy is known and controlled by the algorithm. Methods for reducing the bias due to adaptive data collection have also been studied for non-contextual multi-armed bandits villar-online, nie-online, but the nature of the estimation in contextual bandits is qualitatively different. Importance weighted regression in contextual bandits was first mentioned in agarwal-ilovetoconbandits, but without a systematic motivation, analysis and evaluation of this technique. To our knowledge, our paper is the first work to integrate balancing in the online contextual bandit setting, to perform a large-scale evaluation of it against direct estimation method baselines with theoretical guarantees and to provide a theoretical characterization of balanced contextual bandits that match the regret bound of their direct method counterparts. The effect of importance weighted regression is also evaluated in bietti2018contextual, but this paper is a successor to the extended version of our paper.
Reweighting or balancing methods address model misspecification by making the estimation “doubly-robust,”, robust against misspecification of the reward function, important here, and robust against the specification of the propensity score (not as important here because in the bandit setting we know the propensity score). The term “doubly-robust” comes from the extensive literature on offline policy evaluation scharfstein1999adjusting; it means that when comparing two policies using historical data, we get consistent estimates of the average difference in outcomes for segments of the context whether we have either a well-specified model of rewards or not., because we have good model of the arm assignment policy (i.e., accurate propensity scores). In a contextual bandit, the learner controls the arm assignment policy conditional on the observed context and therefore has access to accurate propensity scores even in small samples. So, even when the reward model is severely misspecified, the learner can obtain more accurate value estimates of the reward function for each value of the context.
In real-world applications, such as health, education, recommender systems, there may be contextual variables that are highly predictive of user outcomes (e.g. previous health metrics, previous test scores, or previous consumer choices), but less important for optimizing arm assignment. We continue by showing that such contextual variables can be particularly problematic in terms of generating bias and variance in the early stages of learning. Even though in principle a variety of methods can be used to consistently estimate outcome models in the presence of complex, non-uniform arm assignment in large samples (Ridge regression as in agrawal-lints, li-linucb, ordinary least squares as in goldenshluger-olsucb, LASSO as in bastani-lassobandit), in the early stages of learning where samples are small, these methods are only partially effective, and so the extent to which the method exacerbates the estimation problem will affect performance. In the domain of linear contextual bandits, we simplify the assignment policy by simplifying the estimated outcome model. We develop the bootstrap LASSO Thompson sampling and UCB contextual bandits, which use $L_1$ regularization in the estimation of the outcome models and circumvent the lack of closed-form solution by using the bootstrap to form a sampling distribution of the outcomes in order to obtain an approximate posterior for Thompson sampling and an upper confidence bound for UCB. We also propose a method to simplify the assignment policy with a form of smoothing that partitions the context space via a classification tree and defines the assignment rule for each partition rather than for each context distinctly. We show that, all else equal, using assignment policies that are simpler (in terms of how they vary with contextual variables) in the early learning phases of the algorithm can improve the rate of learning and decrease regret. Simple assignment rules may have other advantages as well; for example, lei-mhealth highlights the advantages of simplicity for interpretability in health applications of contextual bandits.
In contextual bandits, contexts $x_1, x_2, \dots, x_T \in \mathcal{X} \subset \mathbb{R}^d$ arrive sequentially. We have a finite set of $K$ arms, $\mathcal{A} = \{1,2,\dots, K\}$, which we wish to assign to each context upon its arrival. We posit that the data $(x_t, r_t(1), r_t(2), \dots, r_t(K))$ are drawn iid from a fixed underlying joint distribution on $(x, r(1), r(2), \dots, r(K))$, where $r(a) \in \mathbb{R}$ denotes the (random) reward under arm $a$ and context $x$. Note that the marginal distribution on $x$ specifies the distribution from which the contexts are drawn. The observables are $(x_t, a_t, r_t(a_t))$; in particular, only the reward $r_t(a_t)$ for the chosen arm $a_t$ is observed. For each context $x\in \mathbb{R}^d$, the optimal assignment is $a^*(x) = \operatorname*{argmax}_{a}\left\{\mathbb{E}[r(a) | x]\right\}$ and we let $a_t^* = a^*(x_t)$, which denotes the optimal assignment for context $x_t$. The objective is to find an assignment rule that sequentially assigns $a_t$ to minimize the cumulative expected regret $\sum_{t=1}^\top \mathbb{E} [r(a^*_t) - r(a_t)]$, where the assignment rule is a function of the previous observations $\left(x_j, a_j, r(a_j)\right)$ for $j=1,\dots,t-1$ and of the new context $x_t$. We next discuss three methodological designs in contextual bandits.
An important component for sequential arm assignment lies in modeling and estimating the conditional expected reward corresponding to each arm $a \in \mathcal{A}$ given context $x$, $\mu_a(x) = \mathbb{E}[r(a) | x]$. In a contextual bandit there are as many models to be estimated as arms. We do this estimation separately for each arm $a \in \mathcal{A}$ on the history of observations corresponding to this arm $\{\left(x_t, a_t, r_t(a_t)\right) \mid a_t = a\}$.
In parametric estimation, we estimate $\mu_a(x)$ by a parametric form. A commonly used model in contextual bandits is the linear model, where $\mu_a(x) = x^\top \theta_a$, with unknown parameters $\theta_a$. More generally, estimation can be done via generalized linear models\footnote{GLM bandits are discussed in li-glmucb.} $\mu_a(x) = g(x^\top \theta_a)$, where $g: \mathbb{R} \to \mathbb{R}$ is a strictly increasing and known link function. Denote r$_a$ as the response vector and X$_a$ as the covariate matrix of the history of observations assigned to $a$. The model parameters can be estimated via $L_1$ (LASSO tibshirani-lasso in linear models) or $L_2$ (ridge hoerl-ridge in linear models) regularized regression. For a new context $x$, we wish to obtain the conditional mean $\hat{\mu}_a(x)$ of the reward associated with each arm $a \in A$ and its variance $\mathbb{V}(\hat{\mu}_a(x))$. In some cases, the estimates can be computed in closed form (e.g. in the case of a linear model estimated with ridge regression). However, in many cases (e.g. in the case of a linear model estimated with LASSO regression, or generalized linear models) exact computation is intractable and we must perform approximation russo2018tutorial. When exact computation is intractable, bootstraping provides a viable way to approximate these quantities. More specifically, we can obtain a sampling distribution on $\mu_a(x)$ by training many regularized regression models on bootstrap samples drawn from $(\textbf{X}_a, \textbf{r}_a)$. With this sampling distribution, we can then easily to compute the mean estimate $\hat{\mu}_a(x)$ and the variance estimate $\mathbb{V}(\hat{\mu}_a(x))$. Note that as long as one can solve the underlying regression problem efficiently (either in closed form or via some fast numeric scheme), the estimates can be constructed by bootstraping. Consequently, this provides a general-purpose way of computing $\hat{\mu}_a(x)$ and estimate $\mathbb{V}(\hat{\mu}_a(x))$ for contextual bandits.
Parametric estimation can have high bias when the model is mis-specified (also called unrealizable in the literature). Non-parametric models, on the other hand, are more expressive and comparatively suffer less from the bias problem. In this paper, we consider non-parametric estimation of $\mu_a(x)$ by training a generalized random forest athey-grf on the history of observations assigned to $a$. Generalized random forest is an ensemble method and hence provides estimates of the conditional mean $\hat{\mu}_a(x)$ and variance $\mathbb{V}(\hat{\mu}_a(x))$. Related approaches based on random forests or decision trees have been proposed in feraud-banditforest, elmachtoub-decisiontreesbootstrap. The generalized random forest is a method that preserves the core elements of random forests breiman-rf including recursive partitioning, sub-sampling, and random split selection, but differs from traditional approaches in several ways, most notably that it integrates “honest” tree estimation athey-ct: the sample used to select the splits of the tree is independent from the sample used to estimate the improvement in fit yielded by a split. The “honesty” property of generalized random forests reduces bias and overfitting to outliers, which may be of particular concern in early stages of learning. In cases where the outcome functional form is complicated, as is often the case in practice, bandits based on non-parametric estimation tend to perform better. In addition, they can flexibly control for features which are confounders for the estimation of the reward functions (i.e., features that affect outcomes and were also used to determine assignments in earlier contexts).
Thompson sampling thompson-ts, scott-ts, agrawal-ts, russo-tstutorial and upper confidence bound (UCB) lai-ucb, auer-ucb are two different methods for assigning contexts to arms which are highly effective in dealing with the exploration-exploitation trade-off. In both methods, until every arm has been pulled at least once, the first contexts are assigned to arms in $\mathcal{A}$ at random with equal probability. At every time $t$ and for every arm $a$, the two methods use the history of observations $\{\left(x_t, a_t, r_t(a_t)\right) \mid a_t = a\}$, to obtain the estimates of the functions $\hat{\mu}_a(x)$ and $\mathbb{V}(\hat{\mu}_a(x))$ with the methods outlined in Section (ref).
Thompson sampling assumes that the expected reward $\mu_a(x_t)$ associated with arm $a$ conditional on the context $x_t$ is Gaussian $ \mathcal{N}\left(\hat{\mu}_a(x_t), \alpha^2\mathbb{V}(\hat{\mu}_a(x_t)) \right)$, where $\alpha$ is an appropriately chosen constant. Then, it draws a sample $\tilde{\mu}_a(x_t)$ from the distribution of each arm $a \in \cal$ and context $x_t$ is then assigned to the arm with the highest sample, $a_t = \operatorname*{argmax}_a \{\tilde{\mu}_{a}(x_t)\}$.
On the other hand, UCB computes upper confidence bounds for the expected reward $\mu_a(x_t)$ of context $x_t$ associated with each arm $a \in \mathcal{A}$ and assigns the context to the arm with the highest upper confidence bound, $a_t = \operatorname*{argmax}_a\left\{\hat{\mu}_a(x_t) + \alpha \sqrt{\mathbb{V}(\hat{\mu}_a(x_t))}\right\}$, where $\alpha$ is an appropriately chosen constant.
In this section, we use balancing methods from the causal inference literature to improve the existing UCB and Thompson sampling algorithms by balancing features between arms to reduce bias. We focus on the method of inverse propensity weighting (IPW) imbens-ci. Denote r as the reward vector, X as the context matrix and a as the arm assignment vector of all previous observations.
For UCB, we train a multi-class logistic regression model of a on X to estimate the assignment probabilities $p_a(x), a \in \mathcal{A}$, also known as propensity scores. Note that UCB has deterministic assignment rules, so that conditional on the batch, the propensity scores are either zero or one. However, we can consider the ordering of contexts' arrival as random and use $\hat{p}_a(x)$ as a balancing weight to account for non-uniform assignment in previous contexts.
For Thompson sampling, the propensity scores are in principle known because Thompson sampling performs probability matching, i.e., it assigns a context to an arm with the probability that this arm is optimal. Since computing the propensity scores involves high order integration, they can be approximated via Monte-Carlo simulation. Each iteration draws a sample from the posterior reward distribution of every arm $a$ conditional on $x$, where the posterior is the one that the algorithm considered at the end of a randomly selected prior time period. The propensity score $p_a(x)$ is the fraction of the Monte-Carlo iterations in which arm $a$ has the highest sampled reward, where the arrival time of context $x$ is treated as random.
With these propensity estimates, we can modify the model estimation as follows. For parametric estimation, we define the weight of each observation $(x, a, r)$ as the inverse of the estimated propensity score, $$w_a = 1/\hat{p}_{a}(x)$$ and we train the weighted counterparts of the regularized regressions discussed in Section (ref). For non-parametric estimation (via generalized random forest), one alternative is to construct an augmented covariate matrix $\tilde{\textbf{X}}_a$ and reward vector $\tilde{\textbf{r}}_a$ by replicating $[w_a]$ times each observation $(x,a,r)$ and subsequently to estimate the generalized random forest on $\tilde{\textbf{X}}_a$ and $\tilde{\textbf{r}}_a$. Another alternative is to treat the propensity score of each observation as a contextual variable and estimate the generalized random forest on $[\textbf{X}_a : \textbf{p}_a]$ and $\textbf{r}_a$, where $\textbf{p}_a$ is the vector of the propensity scores for previous observations for arm $a$.
In both cases, weighting the observations by the inverse propensity scores reduces bias, but even when the propensity scores are known it increases variance, particularly when they are small. Consequently, since eventually assignment probabilities should approach zero or one for all arms and contexts clipping the propensity scores crump2009dealing,kallus2018policy with some threshold $\gamma$, e.g. $0.1$ helps control the variance increase.
Finally, note that one could integrate in the contextual bandit estimation other covariate balancing methods, such as the method of approximate residual balancing athey-arb or the method of kallus-offline. For instance, with approximate residual balancing one would use as weights $$w_a = \operatorname*{argmin}_w \left\{ (1- \zeta) \lVert w\rVert_2^2 + \zeta \lVert \bar{x} - \textbf{X}_a^\top w \rVert_\infty^2 \text{ s.t. } \sum_{t: a_t = a} w_t = 1 \text{ and } 0 \leq w_t \leq n_a^{-2/3} \right\}$$ where $\zeta \in (0, 1)$ is a tuning parameter, $n_a = \sum_{t = 1}^{T} \textbf{1} \{a_t = a\}$ and $\bar{x} = \frac{1}{T} \sum_{t = 1}^{T} x_t$ and then use $w_a$ to modify the parametric and non-parametric model estimation as outlined before.
In this section, we study empirically and theoretically the effects of balancing as introduced in (ref). For concreteness, we focus on the method of inverse propensity weighting for balancing and on linear models with $L_2$ regularization (i.e. ridge) and refer to the resulting algorithms as balanced linear Thompson sampling (BLTS) and balanced linear upper confidence bound (BLUCB), as given in Algorithm (ref) and Algorithm (ref).
BLTS and BLUCB build on linear contextual bandits LinTS agrawal-lints and LinUCB li-linucb respectively. In LinTS and LinUCB, the expected reward is assumed to be a linear function of the context $x_t$ with some unknown coefficient vector $\theta_a$, $\mathbb{E}[r_t(a) | x_t = x] = x^\top \theta_a$, and the variance is typically assumed to be constant $\mathbb{V}[r_t(a) | x_t = x] = \sigma^2_a$. At time $t$, LinTS and LinUCB apply ridge regression with regularization parameter $\lambda$ to the history of observations $(X_a, r_a)$ for each arm $a \in \mathcal{A}$, in order to obtain an estimate $\hat{\theta}_a$ and its variance $\mathbb{V}_a(\hat\theta_a)$. For the new context $x_t$, $\hat{\theta}_a$ and its variance are used by LinTS and LinUCB to obtain the conditional mean $\hat{\mu}_a(x_t)=x_t^\top\hat\theta_a$ of the reward associated with each arm $a \in A$, and its variance $\mathbb{V}(\hat{\mu}_a(x_t))=x^\top_t \mathbb{V}(\hat\theta_a) x_t $.
BLTS and BLUCB are linear contextual bandit algorithms that perform balanced estimation of the model of all arms in order to obtain a Gaussian distribution and an upper confidence bound respectively for the reward associated with each arm conditional on the context. The idea is that at every time $t$, the linear contextual bandit weighs each observation $(x_\tau, a_\tau, r_\tau(a_\tau))$, $\tau = 1, \dots, t$ in the history up to time $t$ by the inverse propensity score, $p_{a_\tau}(x_\tau)$. Then, for each arm $a \in \mathcal{A}$, the linear contextual bandit weighs each observation $(x_\tau, a, r_\tau(a))$ in the history of arm $a$ by $w_{a} = 1 / p_{a}(x_\tau)$ and uses weighted regression to obtain the estimate $\hat{\theta}^\text{balanced}_a$ with variance $\mathbb{V}(\hat\theta^\text{balanced}_a)$.
In BLTS (Algorithm (ref)), the observations are weighted by the known propensity scores. For every arm $a$, the history $(X_a, r_a, p_a)$ is used to obtain a balanced estimate $\hat{\theta}^\text{BLTS}_a$ of $\theta_a$ and its variance $\mathbb{V}(\hat\theta^\text{BLTS}_a)$ which produce a normally distributed estimate of $\tilde{\mu}_a \sim \mathcal{N}\left(x_t^\top \hat{\theta}^\text{BLTS}_a, \alpha^2 x_t^\top \mathbb{V}(\hat\theta^\text{BLTS}_a) x_t\right)$ of the reward of arm $a$ for context $x_t$, where $\alpha$ is a parameter of the algorithm.
In BLUCB (Algorithm (ref)), the observations are weighted by the estimated propensity scores. For every arm $a$, the history $(X_a, r_a, \hat{p}_a)$ is used to obtain a balanced estimate $\hat{\theta}^{\text{BLUCB}}_a$ of $\theta_a$ and its variance $\mathbb{V}(\hat\theta^\text{BLUCB}_a)$. These are used to construct the upper confidence bound, $x_t^\top \hat{\theta}_a + \alpha \sqrt{x_t^\top \mathbb{V}(\hat\theta^\text{BLUCB}_a) x_t}$, for the reward of arm $a$ for context $x_t$, where $\alpha$ is a constant. (For some results, e.g., auer2002using, $\alpha$ needs to be slowly increasing in $t$.)
We present computational results that compare the performance of BLTS and BLUCB, with the existing state-of-the-art linear contextual bandits algorithms LinTS agrawal-lints and LinUCB li-linucb. More specifically, we first present a simple synthetic example that simulates bias in the training data by under-representation or over-representation of certain regions of the context space and investigates the performance of the considered linear contextual bandits both when the outcome model of the arms matches the true reward generative process and when it does not match the true reward generative process. Second, we conduct an experiment by leveraging 300 public, supervised cost-sensitive classification datasets to obtain contextual bandit problems, treating the features as the context, the labels as the arms and revealing only the reward for the chosen label. We show that BLTS performs better than LinTS and that BLUCB performs better than LinUCB. The randomized assignment nature of Thompson sampling facilitates the estimation of the arms' outcomes models compared to UCB, and as a result LinTS outperforms LinUCB and BLTS outperforms BLUCB. Overall, BLTS has the best performance. In the supplemental material, we include experiments against the policy-based contextual bandit from agarwal-ilovetoconbandits which is statistically optimal but it is also outperformed by BLTS. Finally, we give a theoretical guarantee that matches the existing regret performance of BLTS and BLUCB.
This simulated example aims to reflect in a simple way two issues that often arise in practice. The first issue is the presence of bias in the training data by under-representation or over-representation of certain regions. A personalized policy that is trained based on such data and is applied to the entire context space will result in biased decisions for certain contexts. The second issue is the problem of mismatch between the true reward generative process and the functional form used for estimation of the outcome model of the arms, which is common in applications with complex generative models. Model mis-specification aggravates the presence of bias in the learned policies.
We use this simple example to present in an intuitive manner why balancing and randomized assignment rule help with these issues, before moving on to a large-scale evaluation of the algorithms in real datasets in the next section.
Consider a simulation design where there is a warm-start batch of training observations, but it consists of contexts focused on one region of the context space. There are three arms $\mathcal{A} = \{0, 1, 2\}$ and the contexts $x_t = (x_{t,0}, x_{t,1})$ are two-dimensional with $x_{t,j} \sim \mathcal{N}(0, 1), \enskip j \in \{0, 1\}$. The rewards corresponding to each arm $a \in \mathcal{A}$ are generated as follows; $r_t(0) = 0.5 (x_{t,0} + 1)^2 + 0.5 (x_{t,1} + 1)^2 + \epsilon_t$, $r_t(1) = 1 + \epsilon_t$, and $r_t(2) = 2 - 0.5 (x_{t,0} + 1)^2 - 0.5 (x_{t,1} + 1)^2 +\epsilon_t$, where $\epsilon_t \sim \mathcal{N}(0, \sigma^2)$, $\sigma^2 = 0.01$. The expected values of the three arms' rewards are shown in Figure (ref).
In the warm-start data, $x_{t,0}$ and $x_{t,1}$ are generated from a truncated normal distribution $\mathcal{N}(0, 1)$ on the interval $(-1.15, -0.85)$, while in subsequent data $x_{t,0}$ and $x_{t,1}$ are drawn from $\mathcal{N}(0, 1)$ without the truncation. Each one of the 50 warm-start contexts is assigned to one of the three arms at random with equal probability. Note that the warm-start contexts belong to a region of the context space where the reward surfaces do not change much with the context. Therefore, when training the reward model for the first time, the estimated reward of arm $a = 2$ (blue) is the highest, the one of arm $a = 1$ (yellow) is the second highest and the one of arm $a = 0$ (red) is the lowest across the context space.
We run our experiment with a learning horizon $T = 10000$. The regularization parameter $\lambda$, which is present in all algorithms, is chosen via cross-validation every time the model is updated. The constant $\alpha$, which is present in all algorithms, is optimized among values $0.25, 0.5, 1$ in the Thompson sampling bandits (the value $\alpha=1$ corresponds to standard Thompson sampling, chapelle-tsucb suggest that smaller values may lower regret) and among values $1, 2, 4$ in the UCB bandits chapelle-tsucb. The propensity threshold $\gamma$ for BLTS and BLUCB is optimized among the values $0.01, 0.05, 0.1, 0.2$.
In this section, we compare the behavior of LinTS, LinUCB, BLTS and BLUCB when the outcome model of the contextual bandits is well-specified, i.e., it includes both linear and quadratic terms. Note that this is still in the domain of linear contextual bandits, if we treat the quadratic terms as part of the context.
First, we compare LinTS and LinUCB. Figure (ref) shows that the uncertainty and the stochastic nature of LinTS leads to a “dispersed” assignment of arms $a=1$ and $a=2$ and to the crucial assignment of a few contexts to arm $a = 0$. This allows LinTS to start decreasing the bias in the estimation of all three arms in the subsequent time periods. Within the first few learning observations, LinTS estimates the outcome models of all three arms correctly and finds the optimal assignment. On the other hand, Figure (ref), shows that the deterministic nature of LinUCB assigns entire regions of the context space to the same arm. As a result not enough contexts are assigned to $a=0$ and LinUCB delays the correction of bias in the estimation of this arm. Another way to understand the problem is that the outcome model in the LinUCB bandit has biased coefficients combined with estimated uncertainty that is too low to incentivize the exploration of arm $a = 0$ initially. LinUCB finds the correct assignment after 240 observations.
Second, we study the performance of BLTS and BLUCB. In Figure (ref), we observe that balancing has a significant impact on the performance of UCB, since BLUCB finds the optimal assignment after 110 observations, much faster than LinUCB. This is because the few observations of arm $a = 0$ outside of the context region of the warm-start batch are weighted more heavily by BLUCB. As a result, BLUCB, despite its deterministic nature which complicates estimation, is able to reduce its bias more quickly via balancing Figure (ref) shows that BLTS is also able to find the optimal assignment a few observations earlier than LinTS. Figure (ref) shows the evolution of the estimation bias for all three arms for the well-specified LinTS, LinUCB, BLTS and BLUCB.
The first column of Table (ref) shows the percentage of simulations in which LinTS, LinUCB, BLTS and BLUCB find the optimal assignment within $T = 10000$ contexts for the well-specified case. BLTS outperforms all other algorithms by a large margin.
We now study the behavior of LinTS, LinUCB, BLTS and BLUCB when the outcome models include only linear terms of the context and therefore are mis-specified. In real-world domains, the true data generative process is complex and very difficult to capture by the simpler outcome models assumed by the learning algorithms. Hence, model mismatch is very likely.
We first compare LinTS and LinUCB. In Figures (ref), (ref), we see that during the first time periods, both bandits assign most contexts to arm $a = 2$ and a few contexts to arm $a = 1$. LinTS finds faster than LinUCB the linearly approximated area in which arm $a = 2$ is suboptimal. However, both LinTS and LinUCB have trouble identifying that the optimal arm is $a = 0$. Due to the low estimate of $a = 0$ from the mis-representative warm-start observations, LinUCB does not assign contexts to arm $a = 0$ for a long time and therefore, delays to estimate the model of $a = 0$ correctly. LinTS does assign a few contexts to arm $a = 0$, but they are not enough to quickly correct the estimation bias of arm $a = 0$ either. On the other hand, BLTS is able to harness the advantages of the stochastic assignment rule of Thompson sampling. The few contexts assigned to arm $a = 0$ are weighted more heavily by BLTS. Therefore, as shown in Figure (ref), BLTS corrects the estimation error of arm $a = 0$ and finds the (constrained) optimal assignment already after 20 observations. On the other hand, BLUCB does not handle better than LinUCB the estimation problem created by the deterministic nature of the assignment in the mis-specified case, as shown in Figure (ref). Figure (ref) shows the evolution of the estimation bias for all three arms for the mis-specified LinTS, LinUCB, BLTS and BLUCB.
The second column of table (ref) shows the percentage of simulations in which LinTS, LinUCB, BLTS and BLUCB find the optimal assignment within $T = 10000$ contexts for the mis-specified case. Again, BLTS has a strong advantage.
This simple synthetic example allowed us to explain transparently where the benefits of balancing in linear bandits stem from. Balancing helps escape biases in the training data and can be more robust in the case of model mis-specification. While, as we proved, balanced linear contextual bandits share the same strong theoretical guarantees, this indicates towards their better performance in practice compared to other contextual bandits with linear realizability assumption. We investigate this further in the next section with an extensive evaluation on real cost-sensitive classification datasets.
Adapting a classification task to a bandit problem is a common method for comparing contextual bandit algorithms dudik-offline-1, agarwal-ilovetoconbandits, bietti2018contextual. In a classification task, we assume data are drawn IID from a fixed distribution: $(x, c) \sim D$, where $x \in \mathcal{X}$ is the context and $c \in {1, 2, \dots, K}$ is the class. The goal is to find a classifier $\pi: \mathcal{X} \rightarrow \{1, 2, \dots, K\}$ that minimizes the classification error $\mathbb{E}_{(x, c) \sim D}\mathbf{1}\left\{\pi(x) \neq c\right\}$. The classifier can be seen as an arm-selection policy and the classification error is the policy's expected regret. Further, if only the loss associated with the policy's chosen arm is revealed, this becomes a contextual bandit setting. So, at time $t$, context $x_t$ is sampled from the dataset, the contextual bandit selects arm $a_t \in \{1, 2, \dots, K\}$ and observes reward $r_t(a_t) = \mathbf{1}\left\{a_t = c_t\right\}$, where $c_t$ is the unknown, true class of $x_t$. The performance of a contextual bandit algorithm on a dataset with $n$ observations is measured with respect to the normalized cumulative regret, $\frac{1}{n} \sum_{t =1}^n{\left(1 - r_t(a_t)\right)}$.
We use 300 multiclass datasets from the Open Media Library (OpenML). The datasets vary in number of observations, number of classes and number of features. Table (ref) summarizes the characteristics of these benchmark datasets. Each dataset is randomly shuffled.
We evaluate LinTS, BLTS, LinUCB and BLUCB on these 300 benchmark datasets. We run each contextual bandit on every dataset for different choices of input parameters. The regularization parameter $\lambda$, which is present in all algorithms, is chosen via cross-validation every time the model is updated. The constant $\alpha$, which is present in all algorithms, is optimized among values $0.25, 0.5, 1$ in the Thompson sampling bandits chapelle-tsucb and among values $1, 2, 4$ in the UCB bandits chapelle-tsucb. The propensity threshold $\gamma$ for BLTS and BLUCB is optimized among the values $0.01, 0.05, 0.1, 0.2$. Apart from baselines that belong in the family of contextual bandits with linear realizability assumption and have strong theoretical guarantees, we also evaluate the policy-based ILOVETOCONBANDITS (ILTCB) from agarwal-ilovetoconbandits that does not estimate a model, but instead it assumes access to an oracle for solving fully supervised cost-sensitive classification problems and achieves the statistically optimal regret.
Figure (ref) shows the pairwise comparison of LinTS, BLTS, LinUCB, BLUCB and ILTCB on the 300 classification datasets. Each point corresponds to a dataset. The $x$ coordinate is the normalized cumulative regret of the column bandit and the $y$ coordinate is the normalized cumulative regret of the row bandit. The point is blue when the row bandit has smaller normalized cumulative regret and wins over the column bandit. The point is red when the row bandit loses from the column bandit. The point's size grows with the significance of the win or loss.
The first important observation is that the improved model estimation achieved via balancing leads to better practical performance across a large number of contextual bandit instances. Specifically, BLTS outperforms LinTS and BLUCB outperforms LinUCB. The second important observation is that deterministic assignment rule bandits are at a disadvantage compared to randomized assignment rule bandits. The improvement in estimation via balancing is not enough to outweigh the fact that estimation is more difficult when the assignment is deterministic and BLUCB is outperformed by LinTS. Overall, BLTS which has both balancing and a randomized assignment rule, outperforms all other linear contextual bandits with strong theoretical guarantees. BLTS also outperforms the model-agnostic ILTCB algorithm.
We refer the reader to Appendix B of the supplemental material for details on the datasets.
Here we establish theoretical guarantees of BLTS and BLUCB that are comparable to LinTS and LinUCB. We start with a few technical assumptions that are standard in the contextual bandits literature.
We use the standard (frequentist) regret criterion to measure performance as defined next:
Next, we make the standard assumptions on the regularity of the distributions:
We refer the reader to Appendix A of the supplemental material for the regret bound proofs.
In this section, we investigate three additional estimation considerations and present further evidence from simulations that demonstrate our design outlined in Section (ref) can be more effective in a variety of different contexts.
In contextual bandits, the assignment to an arm is a function of the contexts and not all contexts have the same assignment probabilities. This creates an environment with confounding, often in combination with small samples, in which the choice of the estimation method plays a very significant role. In this section, we study the significance maintaining a simple outcome model in contextual bandits. The potential outcome models corresponding to each arm are estimated in every batch and are used by the bandit to determine the assignment of contexts to arms, e.g. via the construction of upper confidence bounds. Therefore, maintaining a simple outcome model results in a simple assignment model.
We compare a contextual bandit that maintains a simpler outcome model, such as LASSO, with a contextual bandit that maintains a more complex outcome model, such as ridge. As mentioned in (ref), exact computation of the reward mean and variance in the case of LASSO is intractable and we must perform approximation russo2018tutorial. Bootstraping provides a viable way to approximate the quantities. More specifically, we can obtain a sampling distribution on $\mu_a(x)$ by training many regularized regression models on bootstrap samples drawn from $(\textbf{X}_a, \textbf{r}_a)$. With this sampling distribution, we can then easily to compute the mean estimate $\hat{\mu}_a(x)$ and the variance estimate $\hat{\sigma}_a^2(x)$. This section compares bootstrap LASSO Thompson sampling and bootstrap ridge Thompson sampling. In Appendix C, we provide a Bayesian way of using LASSO estimation in a Thompson sampling or UCB contextual bandit motivated by park2008bayesian. The theoretical analysis of Bayesian LASSO contextual bandit may be proven more straightforward than the theoretical analysis of bootstrap LASSO contextual bandit, though we leave this analysis for future work.
Consider a simulation setting where the contexts $x_t$ are $d$-dimensional and $x_t \sim \mathcal{N}(0_d, I_{d})$. There are three arm $\mathcal{A} = \{0, 1, 2\}$ and the potential outcomes are generated as $r_t(0) = x_{t,0} + f(x_t) + \epsilon_t$, $r_t(1) = 1 - x_{t,0} + f(x_t) + \epsilon_t$, and $r_t(2) = x_{t,1} + f(x_t) +\epsilon_t$, where $\epsilon_t \sim \mathcal{N}(0, \sigma^2)$ and $f(x_t)$ is a function that shifts the potential outcomes of all arms. Therefore, in this design, only contextual variables $x_{t,0}$ and $x_{t,1}$ are relevant to the assignment model. Among the remaining $d-2$ contextual variables, there are $q$ nuisance contextual variables that appear in the outcome model, but should not play a role in the assignment model, as their effect to the potential outcomes is the same for all arms. These nuisance contextual variables shift the potential outcomes by $f(x_t) = 2 \sigma \sum_{j = 2}^{q + 1} x_{t,j}$. The remaining $d-q-2$ contextual variables are noise contextual variables and do not play a role in either the assignment or the outcome model.
We choose $d = 102$ and $q = 51$. So, among the 100 non-relevant contextual variables, 51 are nuisance contextual variables and 49 are noise contextual variables. First, we compare LASSO and ridge in terms of fit on 1000 observations, when the assignment of contexts to arms is purely randomized. The number of nuisance contextual variables, $q$, is chosen so that LASSO and ridge perform equivalently in terms of fit on purely randomized data, in order to evaluate the choice of the estimation method in the adaptive setting all else being equal. Indeed, as demonstrated in Figure (ref), the LASSO and ridge models are almost identical in terms of mean squared error (MSE) when trained on batches of randomized data.
Subsequently, we compare the performance of LASSO and ridge in the bandit setting with learning horizon 1000 context. Despite the initial equivalence of LASSO and ridge in the training setting, LASSO clearly outperforms ridge in terms of regret in the adaptive learning setting, as shown in Figure (ref).
The contributing factor to the bandit performance dissimilarity of these seemingly equivalent models on randomized training data is the presence of confounding. In the initial learning observations, a ridge bandit, due to $L_2$ regularization, brings in all of the nuisance and noise contextual variables, as shown in Figures (ref), (ref). The nuisance contextual variables affect assignment (possibly in non-linear ways) and act as confounders. There is insufficient data in the early observations to accurately control for all of them in the outcome model estimation. Both the nuisance and the noise contextual variables create more extreme and variable assignment probabilities, increasing the variance of estimation. A LASSO bandit, due to the $L_1$ regularization, excludes from the outcome model most of the noise contextual variables and initially, the nuisance contextual variables, as shown in Figures (ref), (ref). As a result, in the early observations, there are fewer confounders compared to a ridge bandit. Therefore, in the subsequent stages of learning, there is less bias as well as less noise in the assignment process for the LASSO bandit than for the ridge bandit.
Real-world applications, such as recommendation systems, may have inherently difficult and complex outcome models. In such cases, contextual bandits based on non-parametric model estimation may be more agile. In this section, we compare non-parametric contextual bandits (generalized random forest Thompson sampling) with parametric contextual bandits that make linearity assumptions on the potential outcome models (bootstrap LASSO Thompson sampling and bootstrap ridge Thompson sampling).
Consider a simple non-linear simulation design with $10$-dimensional contexts $x_t$ such that $x_{t,j} \sim \mathcal{N}(0, 1), \enskip j = 0, \dots, 9$. There are three arms $\mathcal{A} = \{0, 1, 2\}$ and the potential outcomes are generated as $r_t(0) = x_{t,0} + \epsilon_t$, $r_t(1) = - x_{t,0} + \epsilon_t$, and $r_t(2) = \mathbf{1}\{ x_{t,1} < 0\} \left(\min\{x_{t,0}, - x_{t,0}\}- 1\right) + \mathbf{1}\{ x_{t,1} > 0\} \left(\max\{x_{t,0}, - x_{t,0}\} + 1\right) + \epsilon_t$, where $\epsilon_t \sim \mathcal{N}(0, \sigma^2)$ with $\sigma = 0.1$. Therefore, only contextual variables $x_{t,0}$ and $x_{t,1}$ are relevant to the arm assignment model. In this design, the correct assignment is $a = 2$ in the first and second quadrants, $a = 1$ in the third quadrant and $a = 0$ in the fourth quadrant. We run the bandits on 5000 observations. The models of LASSO and ridge include quadratic and second order interarm terms, there are $B = 100$ bootstrap samples, and the regularization parameter is chosen via cross-validation. The number of trees in the generalized random forest is $m = 200$ and the tuning parameters are the default, specified in athey-grf and in the \verb|grf| R package.
Figure (ref) shows that the generalized random forest bandit outperforms the LASSO and the ridge bandits. In cases where the outcome functional form is complicated, which is expected in real-world settings, bandits based on non-parametric model estimation may be proven useful and perform better. However, one needs to bear in mind that similarly to the ridge bandit, the generalized random forest bandit creates a complex assignment model and is subject to the disadvantages discussed in Section (ref). In this simulation design, the presence of noise contextual variables leads the LASSO bandit to outperform the ridge bandit. But the inability of the LASSO bandit and the ability of the generalized random forest bandit to fit the potential outcome model of the third arm, results in a strong performance edge of the latter. Figure (ref) shows the assignment evolution in the $(x_{\cdot, 0}, x_{\cdot, 1})$ for the ridge, the LASSO and the generalized random forest bandit. The generalized random forest bandit has the advantage that the outcome model is non-parametric, and thus is able to account for non-linear functions of the contextual variables, in principle reducing problems that might arise if the assignment model is a non-linear function of contextual variables. Additionally, the “honest” estimation property featured by the generalized random forest bandit reduces bias.
So far, we have considered the assignment rule for each context distinctly; the rule depends on the mean and variance of estimates at each context $x$. A literature on optimal policy evaluation in the offline world (e.g. athey-offline) derives efficient methods for offline policy estimation when the policy is constrained to be of limited complexity. One example uses trees of limited depth as the relevant policy class. The method first constructs the efficient score $\hat{\mu}_{a}(x) + \frac{r - \hat{\mu}_{a}(x)}{\hat{p}_{a}(x)}$ for each observation $(x, a, r)$. Subsequently, it estimates a classification tree on the history of contexts $\textbf{X}$ and assignments $\textbf{a}$, weighted by the absolute value of the efficient scores in order to determine the optimal choice of arm in each leaf, where leaves are regions of the context space.
Here, we propose to follow their method to estimate a policy assignment tree. However, we use the output differently: rather than deterministically assigning each context to the estimated optimal policy, instead we use estimates of the mean and variance of each arm within each leaf together with Thompson sampling or UCB to determine assignments. One complication that potentially arises in the online setting is that in the early stages of learning the estimation of the “nuisance parameters” in the efficient score, $\hat{\mu}_{a}(x)$ and $\hat{p}_{a}(x)$, may be noisy due to the small number of observations.
To understand why using simpler assignment rules through a form of smoothing can be beneficial, it is useful to contrast two cases, one where the probability that an arm is best is estimated very precisely, and the second where we have a noisy estimate of that probability. Suppose that sampling according to the true probability balances exploration and exploitation in an ideal way (e.g. that the Thompson sampling heuristic is ideal in a given setting). Then, when shifting to the second case where the probabilities are unknown, adding a small amount of smoothing to the assignment rule will have little effect on the exploitation side of the bandit trade-off (given that the estimates were noisy, a little smoothing does not introduce first-order mistakes in assignment). From a practical perspective, this suggests using simpler assignment rules can improve performance; further, the Thompson sampling heuristic, which incorporates its own form of smoothing by randomizing assignment, may also improve performance over UCB. However, smoothing improves the exploration side of the trade-off, since it enables lower-variance estimation in future batches. Note that simple assignment rules may have other advantages; for example, lei-mhealth highlights the advantages of simplicity for interpretability in health applications of contextual bandits.
Contextual bandits are poised to play an important role in a wide range of applications: In these settings, there are many potential sources of bias in estimation of outcome models, not only due to the inherent adaptive data collection, but also due to mismatch between the true data generating process and the outcome model assumptions, and due to prejudice in the training data in form of under-representation or over-representation of certain regions of the context space. content recommendation in web-services, where the learner wants to personalize recommendations (arm) to the profile of a user (context) to maximize engagement (reward); online education platforms, where the learner wants to select a teaching method (arm) based on the characteristics of a student (context) in order to maximize the student's scores (reward); and survey experiments, where the learner wants to learn what information or persuasion (arm) influences the responses (reward) of subjects as a function of their demographics, political beliefs, or other characteristics (context). In these settings, there are many potential sources of bias in estimation of outcome models, not only due to the inherent adaptive data collection, but also due to mismatch between the true data generating process and the outcome model assumptions, and prejudice in the training data in form of under-representation or over-representation of certain regions of the context space in the cold-start training data. To reduce bias, we proposed new contextual bandit designs which integrate balancing methods from the causal inference literature and parametric and non-parametric model estimation methods with optimism or randomization based exploration methods. We provided the first regret bound analysis for linear contextual bandits with balancing that matches the theoretical guarantees of the linear contextual bandits with direct model estimation We showed that contextual bandit designs with randomization based exploration and balancing in model estimation are more robust to the aforementioned sources of bias and have improved learning rates. We also showed that using simpler, less variable assignment policies, reduces variance in estimation and bias due to confounding and decreases regret. Through a range of simulations and experiments on real-world datasets, we aimed to highlight key tradeoffs and thus provide methodological guidelines to anyone who wishes to efficiently use contextual bandits for learning personalized policies in practice.
The authors would like to thank Emma Brunskill for valuable comments on the paper and John Langford, Miroslav Dud{\'\i}k, Akshay Krishnamurthy and Chicheng Zhang for useful discussions regarding the evaluation on classification datasets. This research is generously supported by ONR grant N00014-17-1-2131, by the Sloan Foundation, by the “Arvanitidis in Memory of William K. Linvill” Stanford Graduate Fellowship in Science & Engineering and by the Onassis Foundation.