Effective Evaluation using Logged Bandit Feedback from Multiple Loggers
Aman Agarwal, Soumya Basu, Tobias Schnabel, Thorsten Joachims
Introduction
Interactive systems (e.g., search engines, ad-placement systems, recommender systems, e-commerce sites) are typically evaluated according to online metrics (e.g., click through rates, dwell times) that reflect the users’ response to the actions taken by the system. For this reason, A/B tests are of widespread use in which the new policy to be evaluated is fielded to a subsample of the user population. Unfortunately, A/B tests come with two drawbacks. First, they can be detrimental to the user experience if the new policy to be evaluated performs poorly. Second, the number of new policies that can be evaluated in a given amount of time is limited, simply because each A/B test needs to be run on a certain fraction of the overall traffic and should ideally span any cycles (e.g. weekly patterns) in user behavior.
Recent work on counterfactual evaluation techniques provides a principled alternative to A/B tests that does not have these drawbacks (Li et al. 2011; Li et al. 2015; Bottou et al. 2013; Swaminathan and Joachims 2015). These techniques do not require that the new policy be deployed online, but they instead allow reusing logged interaction data that was collected by a different policy in the past. In this way, these estimators address the counterfactual inference question of how a new policy would have performed, if it had been deployed instead of the old policy that actually logged the data. This allows reusing the same logged data for evaluating many new policies, greatly improving scalability and timeliness compared to A/B tests.
In this paper, we address the problem of counterfactual evaluation when log data is available not just from one logging policy, but from multiple logging policies. Having data from multiple policies is common to most practical settings where systems are repeatedly modified and deployed. While the standard counterfactual estimators based on inverse propensity scores (IPS) apply to this situation, we show that they are suboptimal in terms of their estimation quality. In particular, we investigate the common setting where the log data takes the form of contextual bandit feedback from a stochastic policy, showing that the variance of the conventional IPS estimator suffers substantially when the historic policies are sufficiently different – to a point where throwing away data improves the variance of the estimator. To overcome the statistical inefficiency of the conventional IPS estimator, we explore two alternative estimators that directly account for the data coming from multiple different logging policies. We show theoretically that both estimators are unbiased, and have lower variance than the conventional IPS estimator. Furthermore, we quantify the amount of variance reduction in an extensive empirical evaluation that demonstrates the effectiveness of both the estimators.
Related Work
The problem of re-using logged bandit feedback is often part of counterfactual learning (Bottou et al. 2013; Li et al. 2015; Swaminathan and Joachims 2015), and more generally can be viewed as part of off-policy evaluation in reinforcement learning (Sutton and Barto 1998; Precup 2000).
In counterfactual learning, solving the evaluation problem is often the first step to deriving a learning algorithm (Strehl et al. 2010; Bottou et al. 2013; Swaminathan and Joachims 2015). The key to being able to counterfactually reason based on logged data is randomness in the logged data. Approaches differ in how randomness is being included in the policies. For example, in (Li et al. 2015) randomization is directly applied to the actions of each policy, whereas (Bottou et al. 2013) randomizes individual policy parameters to create a distribution over actions.
In exploration scavenging (Langford et al. 2008), the authors address counterfactual evaluation in a setting where the actions do not depend on the context. They mention the possibility of combining data from different policies by interpreting each policy as an action. Li et al. (Li et al. 2015) propose to use naturally occurring randomness in the logged data when policies change due to system changes. Since this natural randomness may not be entirely under the operator’s control, the authors propose to estimate the probability that a certain logging policy was in place to recover propensities. The balanced IPS estimator studied in this paper could serve as a starting point for further techniques in that direction.
Evaluation from logged data has often been studied with respect to specific domains, for example in news recommendation (Li et al. 2010; Li et al. 2011; Li et al. 2015) as well as in information retrieval (Hofmann et al. 2013; Li et al. 2015). The work by Li et al. (Li et al. 2011) highlights another common use-case in practice, where different logging policies are all active at the same time, focusing on the evaluation of different new methods. The estimators in this paper can naturally be applied to this scenario as well to augment logging data of one policy with the data from others. An interesting example for probabilistic policies can be found in (Hofmann et al. 2013), where the authors consider policies that are the probabilistic interleaving of two deterministic ranking policies and use log data to pre-select new candidate policies.
Very related to combining logs from different policies is the problem of combining samples coming from different proposal distributions in importance sampling (Owen and Zhou 2000; Owen 2013; Elvira et al. 2015a). There, samples are drawn from multiple proposal distributions and need to be combined in a way that reduces variance of the combined estimator. Multiple importance sampling has been particularly studied in computer graphics (Veach and Guibas 1995), as Monte Carlo techniques are employed for rendering. Most related to the weighted IPS estimator presented later in the paper is adaptive multiple importance sampling (AMIS) (Cornuet et al. 2012; Elvira et al. 2015b) that also recognizes that it is not optimal to weigh contributions from all proposal distributions the same, but instead updates weights as well as the proposal distributions after each sampling step. The most notable differences to our setting here are that (i) we regard the sampling distributions as given and fixed, and (ii) the sampled log data is also fixed. An interesting avenue for future work would be to use control variates to further reduce variance of our estimators (Owen and Zhou 2000; He and Owen 2014), although this approach is computationally demanding since it requires solving a quadratic problem to determine optimal weights.
Another related area is sampling-based evaluation of information retrieval systems (Yilmaz et al. 2008; Carterette et al. 2009; Schnabel et al. 2016). Instead of feedback data that stems from interactions with users, the observed feedback comes from judges. A policy in this case corresponds to a sampling strategy which determines the query-document pairs to be sent out for judgement. As shown by Carterette et al. (Carterette et al. 2009), relying on sampling-based elicitation schemes cuts down the number of required judgements substantially as compared to a classic deterministic pooling scheme. The techniques proposed in our paper could also be applied to the evaluation of retrieval systems when data from different judgement pools need to be combined.
Problem Setting
For example, in ad placement models, the input typically encodes user-specific information as well as the web page content, and the system responds with an ad which is then displayed on the page. Finally, user feedback for the displayed ad is presented, such as whether the ad was clicked or not. Similarly, for a news website, the input may encode user-specific and other contextual information to which the system responds with a personalized home page . In this setting, the user feedback could be the time spent by the user on the news website.
In order to be able to counterfactually evaluate new policies, we consider stochastic policies that define a probability distribution over the output space . Predictions are made by sampling from a policy given input . The inputs are assumed to be drawn i.i.d. from a fixed but unknown distribution . The feedback is a cardinal utility that is only observed at the sampled data points. Large values for indicate user satisfaction with for , while small values indicate dissatisfaction.
We evaluate and compare different policies with respect to their induced utilities. The utility of a policy is defined as the expected utility of its predictions under both the input distribution as well as the stochastic policy. More formally:
Our goal is to re-use the interaction logs collected from multiple historic policies to estimate the utility of a new policy. In this paper, we denote the the new policy (also called the target policy) as , and the logging policies as . The log data collected from each logging policy is
where data-points are collected from logging policy , , , , and . Note that during the operation of the logging policies, the propensities are tracked and appended to the logs. We will also assume that the quantity is available at all pairs. This is a very mild assumption since the logging policies were designed and controlled by us, so their code can be stored. Finally, let denote the combined collection of log data over all the logging policies, and denote the total number of samples.
Unfortunately, it is not possible to directly compute the utility of a policy based on log data using the formula from the definition above. While we have a random sample of the contexts and the target policy is known by construction, we lack full information about the feedback . In particular, we know only for the particular action chosen by the logging policy, but we do not necessarily know it for all the actions that the target policy can choose. In short, we only have logged bandit feedback, but not full-information feedback. This motivates the use of statistical estimators to overcome the infeasibility of exact computation. In the following sections, we will explore three such estimators and focus on two of their key statistics properties, namely their bias and variance.
Naive Inverse Propensity Scoring
A natural first candidate to explore for the evaluation problem using multiple logging policies as defined above is the well-known inverse propensity score (IPS) estimator. It simply averages over all datapoints, and corrects for the distribution mismatch betweenthe logging policies and the target policy using a weighting term:
This is an unbiased estimator as shown below, as long as all logging policies have full support for the new policy .
Policy is said to have support for policy if for all and ,
Assume each logging policy has support for target . For consisting of i.i.d. draws from and logging policies , the naive IPS estimator is unbiased:
The second equality is valid since each has support for . ∎
Note that the requirement that the logging policies have support for the target policy can be satisfied by ensuring that when deploying policies.
We can also characterize the variance of the naive IPS estimator.
Having characterized both the bias and the variance of the Naive IPS Estimator, how does it perform on datasets that come from multiple logging policies?
To illustrate the suboptimality of the Naive IPS Estimator when we have data from multiple logging policies, consider the following toy example where we wish to evaluate a new policy given data from two logging policies and . For simplicity and without loss of generality, consider logged bandit feedback which consists of one sample from and another sample from , more specifically, we have two logs , and . There are two possible inputs and two possible output predictions . The cardinal utility function , the input distribution , the target policy , and the two logging policies and are given in Table 1.
Under closer inspection of Equation (1), the fact that deleting data helps improve variance also makes intuitive sense. Since the overall variance contains the sum of variances over all individual samples, one can hope to improve variance by leaving out high-variance samples. This motivates the estimators we introduce in the following sections, and we will show how weighting samples generalizes this variance-minimization strategy.
Estimator from Multiple Importance Sampling
Having seen that has suboptimal variance, we first explore an alternative estimator used in multiple importance sampling (Owen 2013). We begin with a brief review of multiple importance sampling.
where , and . Directly mapping the above to our setting, we define the Balanced IPS Estimator as follows.
where for all and , .
Note that is a valid policy since the convex combination of probability distributions is a probability distribution. The balanced IPS estimator is also unbiased. Note that it now suffices that has support, but not necessarily that each individual has support.
Assume the policy has support for target . For consisting of i.i.d. draws from and logging policies , the Balanced IPS Estimator is unbiased:
The second equality is valid since has support for . ∎
The variance of can be computed as follows:
A direct consequence of Theorem 1 in (Veach and Guibas 1995) is that the variance of the balanced estimator is bounded above by the variance of the naive estimator plus some positive term that depends on and the log sizes .
Here, we provide a stronger result that does not require an extra positive term for the inequality to hold.
Assume each logging policy has support for target . We then have that
From Equation 1, we have the following expression.
For convenience, and without loss of generality, assume , and therefore, . This is easily achieved by re-labeling the logging policies so that each data-sample comes from a distinctly labeled policy (note that we don’t need the logging policies to be distinct in our setup). Also, for simplicity, let . Then
Thus, it is sufficient to show the following two inequalities
We get Equation 2 by applying Cauchy-Schwarz as follows
Another application of Cauchy-Schwarz gives us Equation 3 in the following way
Weighted IPS Estimator
We have seen that the variances of both the Naive and the Balanced IPS estimators can be reduced by removing some of the data points. More generally, we now explore estimators that re-weight samples from various logging policies based on their relationship with the target policy. This is similar to ideas that are used in Adaptive Multiple Importance Sampling (Cornuet et al. 2012; Elvira et al. 2015b) where samples are also re-weighted in each sampling round. In contrast to the latter scenario, here we assume the logging policies to be fixed, and we derive closed-form formulas for variance-optimal estimators. The general idea of the weighted estimators that follow is to compute a weight for each logging policy that captures the mismatch between this policy and the target policy. In order to characterize the relationship between a logging policy and the new policy to be evaluated, we define the following divergence. This formalizes the notion of mismatch between the two policies in terms of the Naive IPS Estimator variance.
Suppose policy has support for target policy . Then the divergence from to is
Recall that is the utility of policy .
Note that is not necessarily minimal when . In fact, it can easily be seen by direct substitution that where is the optimal importance sampling distribution for with . Nevertheless, informally, the divergence from a logging policy to the target policy is small when the logging policy assigns similar propensities to pairs as the importance sampling distribution for the target policy. Conversely, if the logging policy deviates significantly from the importance sampling distribution, then the divergence is large. Based on this notion of divergence, we propose the following weighted estimator:
Assume for all .
where the weights are set to
Note that the assumption is easily satisfied as long as the logging policy is not exactly equal to the optimal importance sampling distribution of the target policy . This is very unlikely given that the utility of the new policy is unknown to us in the first place.
We will show that the Weighted IPS Estimator is optimal in the sense that any other convex combination by that ensures unbiasedness does not give a smaller variance estimator. First, we have a simple condition for unbiasedness:
Assume each logging policy has support for target policy . Consider the estimator
such that and . For consisting of i.i.d. draws from and logging policies , the above estimator is unbiased:
In particular, is unbiased.
Moreover, , which implies is unbiased. ∎
Notice that making the weights equal reduces to . Furthermore, dropping samples from logging policy is equivalent to setting .
To prove variance optimality, note that the variance of the Weighted IPS Estimator for a given set of weights can be written in terms of the divergences.
Assume each logging policy has support for target policy , and . Then, for any estimator of the form as defined in Proposition 6.3
The expression for the variance of can be verified to be as stated by directly substituting (4) into the variance expression in Equation (5). Next, by the Cauchy-Schwarz inequality,
Note that computing the optimal weights exactly requires access to the utility function everywhere in order to compute the divergences . However, in practice, is only known at the collected data samples, and the weights must be estimated. In Section 7.6 we discuss a simple strategy for doing so, along with an empirical analysis of the procedure.
The extent of variance reduction provided by the Weighted IPS Estimator over the Naive IPS Estimator depends only on the relative proportions of divergences and the log data sizes of each logging policy. The following proposition quantifies the variance reduction.
Let be the ratio of divergences and be the ratio of sample sizes of policy and policy . Then the reduction denoted as is
Substituting the expressions for the two variances, we get that
So, normalizing by and , gives the desired expression. Applying the Cauchy-Schwarz inequality gives the upper bound. ∎
For the case of just two logging policies, , it is particularly easy to compute the maximum improvement in variance of the Weighted IPS Estimator over the Naive estimator. The reduction is , which ranges between and depending on and . The benefit of the weighted estimator over the naive estimator is greatest when the logging policies differ substantially, and there are equal amounts of log data from the two logging policies. Intuitively, this is because the weighted estimator mitigates the defect in the naive estimator due to which abundant high variance samples drown out the signal from the equally abundant low variance samples. On the other hand, the scope for improvement is less when the logging policies are similar or when there are disproportionately many samples from one logging policy.
Empirical Analysis
In this section, we empirically examine the properties of the proposed estimators. To do this, we create a controlled setup in which we have logging policies of different utilities, and try to estimate the utility of a fixed new policy. We illustrate key properties of our estimators in the concrete setting of CRF policies for multi-label classification, although the estimators themselves are applicable to arbitrary stochastic policies and structured output spaces.
We choose multi-label classification for our experiments because of the availability of a rich feature space and an easily scalable label space . Three multi-label datasets from the LibSVM repository with varying feature dimensionalities, number of class labels, and number of training samples available are used. The corpus statistics are as summarized in Table 2.
Since these datasets involve multi-label classification, the output space is , i.e., the set of all possible labels one can generate given a set of labels. The input distribution is the empirical distribution of inputs as represented in the test set. The utility function is simply the number of correctly assigned labels in with respect to the given ground truth label .
To obtain policies with different utilities in a systematic manner, we train conditional random fields (CRFs) on incrementally varying fractions of the labeled training set. CRFs are convenient since they provide explicit probability distributions over possible predictions conditioned on an input. However, nothing in the following analysis is specific to using CRFs as the stochastic logging policies, and note that the target policy need not be stochastic at all.
For simplicity and ease of interpretability, we use two logging policies in the following experiments. To generate these logging policies, we vary the training fraction for the first logging policy over , keeping the training fractions for the second logging policy fixed at . Similarly, we generate a CRF classifier representing the target policy by training on fraction of the data. The effect is that we now get three policies where the second logging policy is similar to the target while the similarity of the first logging policy varies over a wide range. This results in a wide range of relative divergences
for the first logging policy on which the relative performance of the estimators depends.
We compare pairs of estimators based on their relative variance since all the estimators being considered are unbiased (so, relative variance 1 signifies the estimators being compared have the same variance). Since the variance of the different estimators scales inversely proportional to the total number of samples, the ratio of their variances depends only on the relative size of the two data logs
but not on their absolute size. We therefore report results in terms of relative size where we vary to explore a large range of data imbalances.
For a fixed set of CRFs as logging and target policies, and the relative size of the data logs, the ratio of the variances of the different estimators can be computed exactly since the CRFs provide explicit distributions over , and is based on the test set. We therefore report exact variances in the following. In addition to the exactly computed variances, we also did some bandit feedback simulations to verify the experiment setup. We employed the Supervised Bandit conversion method (Agarwal et al. 2014). In this method, we iterate over the test features , sample some prediction from the logging policy and record the corresponding loss and propensity to generate the logged data-sets . For various settings of logging policies and amounts of data, we sampled bandit data and obtained estimator values over hundreds of iterations. We then computed the empirical mean and variance of the different estimates to make sure that the estimators were indeed unbiased and closely matched the theoretical variances reported above.
2. Can dropping data lower the variance of U^naive(π¯){\hat{U}_{naive}({\bar{{\pi}}})}?
While we saw that dropping data improved the variance of the Naive IPS Estimator in the toy example, we first verify that this issue also surfaces outside of carefully constructed toy examples. To this effect, Figure 1 plots the variance of the Naive IPS Estimator that uses data only from relative to the variance of when using data from both and . The x-axis varies the relative amount of data coming from and . Each solid circle on the plot corresponds to a training fraction choice for and a log-data-size ratio . A lot-data-size ratio of 0 means that no data from is used, i.e., all data from is dropped. The relative divergence is higher when is trained on a lower fraction of training data since in that case differs more from . A solid circle below the baseline at indicates that dropping data improves the variance in that case.
Overall, the experiments confirm that the Naive IPS Estimator shows substantial inefficiency. We observe that for high and small , dropping data from can reduce the variance substantially for a wide range of realistic CRF policies. As decreases and increases, dropping data becomes less beneficial, ultimately becoming worse than the using all the data. This concurs with the intuition that dropping a relatively small number of high variance data samples can help utilize the low variance data samples.
3. How does U^bal(π¯){\hat{U}_{bal}({\bar{{\pi}}})} compare with U^naive(π¯){\hat{U}_{naive}({\bar{{\pi}}})}?
We proved that the Balanced IPS Estimator has smaller (or equal) variance than the Naive IPS Estimator. The experiments reported in Figure 2 show the magnitude of variance reduction for . In particular, Figure 2 reports the variance of the Balanced IPS Estimator relative to the variance of the Naive IPS Estimator for different logging policies and different data set imbalances. In all cases, performs at least as well as and the variance reduction increases when the two policies differ more (i.e. is large). The variance reduction due to decreases as the relative size of the log data from increases.
We know that the Weighted IPS Estimator always has lower variance (or equal) than the Naive IPS Estimator. The results in Figure 3 show the magnitude of the relative variance improvement for the Weighted IPS Estimator. As in the case of the Balanced IPS Estimator, performs better than especially when the two logging policies differ substantially. This confirms the theoretical characterization of from Section 6.1, where we computed the variance reduction given and . The empirical findings are as expected by the theory and show a substantial improvement in this realistic setting. However, note that these experiments do not yet address the question of how to estimate the weights in practice, which we come back to in Section 7.6.
We did not find theoretical arguments whether is uniformly better than or vice versa. The empirical results in Figure 4 confirm that either estimator can be preferable in some situations. Specifically, performs better when the difference between the two logging policies is large, whereas performs better when they are closer. This is an interesting phenomenon that merits future investigation. In particular, one might be able to combine the strengths of and to get a weighted form of the estimator. Since we know from the toy example that even can have lower variance with dropping data, it is plausible that it could improve if the samples were weighted non-uniformly.
6. How can we estimate the weights for U^weight(π¯){\hat{U}_{weight}({\bar{{\pi}}})}?
We derived the optimal weights in terms of . Computing the divergence exactly requires access to the utility function on the entire domain . However, is known only at the samples collected as bandit feedback. We propose the following strategy to estimate the weights in this situation.
Each divergence can be estimated by using the empirical variance of the importance-weighted utility values available in the log data .
Under mild conditions, this provides a consistent estimate since and . The weights are then obtained using the estimated divergences.
We tested this method by generating bandit data using the Supervised Bandit conversion method described in Section 7.1 for each logging policy, and then computing the weights as described above. Figure 5 compares the variance of the weighted estimator with the estimated weights against the variance with the optimal weights. The x-axis varies the size of the log data for both logging policies and which are kept equal (i.e. ) for simplicity. As shown, the variance of the estimator with the estimated weights converges to that of the optimal weighted estimator within a few hundred samples for all choices of logging policies and across the three data-sets. Similar trends were observed for other values of relative log data size as well.
Note that in this method we take the empirical variance of the importance-weighted utility values over each log individually to get reliable unbiased estimates of the true divergences. In contrast, the Naive IPS Estimator takes the empirical mean of the same values over the combined data . Therefore, the former estimation does not suffer from the suboptimality in variance that occurs due to naively combining data from different logging policies.
Therefore, we conclude that the above method of estimating the weights performs quite well and seems well suited for practical applications.
Conclusion
We investigated the problem of estimating the performance of a new policy using data from multiple logging policies in a contextual bandit setting. This problem is highly relevant for practical applications since it reflects how logged contextual bandit feedback is available in online systems that are frequently updated (e.g. search engines, ad placement systems, product recommenders). We proposed two estimators for this problem which are provably unbiased and have lower variance than the Naive IPS Estimator. We empirically demonstrated that both can substantially reduce variance across a range of evaluation scenarios.
The findings raise interesting questions for future work. First, it is plausible that similar estimators and advantages also exist for other partial-information data settings (Joachims et al. 2017) beyond contextual bandit feedback. Second, while this paper only considered the problem of evaluating a fixed new policy , it would be interesting to use the new estimators also for learning. In particular, they could be used to replace the Naive IPS Estimator when learning from bandit feedback via Counterfactual Risk Minimization (Swaminathan and Joachims 2015).