{'fraction_non_alphanumeric': 0.04015247776365947, 'fraction_numerical': 0.008204755854056998, 'mean_word_length': 4.255867200915856, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning from Logged Implicit Exploration Data

We provide a sound and consistent foundation for the use of \emph{nonrandom} exploration data in"contextual bandit"or"partially labeled"settings where only the value of a chosen action is learned. The primary challenge in a variety of settings is that the exploration policy, in which"offline"data is logged, is not explicitly known. Prior solutions here require either control of the actions during the learning process, recorded random exploration, or actions chosen obliviously in a repeated manner. The techniques reported here lift these restrictions, allowing the learning of a policy for choosing actions given features from historical data where no randomization occurred or was logged. We empirically verify our solution on two reasonably sized sets of real-world data obtained from Yahoo!.


The Problem
Consider the advertisement display problem, where a search engine company chooses an ad to display which is intended to interest the user. Revenue is typically provided to the search engine from the advertiser only when the user clicks on the displayed ad. This problem is of intrinsic economic interest, resulting in a substantial fraction of income for several well known companies such as Google, Yahoo!, and Facebook. Further-more, existing trends imply this problem is of growing importance.
Before discussing the approach we propose, it's important to formalize and generalize the problem, and then consider why more conventional approaches can fail.

The warm start problem for contextual exploration
Let X be an arbitrary input space, and A = {1, · · · , k} be a set of actions. An instance of the contextual bandit problem is specified by a distribution D over tuples (x, r) where x ∈ X is an input and r ∈ [0, 1] k is a vector of rewards (Langford & Zhang, 2008). Events occur on a round by round basis where on each round t: 1. The world draws (x, r) ∼ D and announces x.
2. The algorithm chooses an action a ∈ A, possibly as a function of x and historical information.
3. The world announces the reward r a of action a.
It is critical to understand that this is not a standard supervised learning problem, because the reward of other actions a ′ = a is not revealed.
The standard goal in this setting is to maximize the sum of rewards r a over the rounds of interaction. In order to do this well, it is essential to use previously recorded events to form a good policy on the first round of interaction. This is known as the "warm start" problem, and is the subject of this paper. Formally, given a dataset of the form S = (x, a, r a ) * generated by the interaction of an uncontrolled logging policy, we want to construct a policy h maximizing (or approximately maximizing) V h := E (x, r)∼D [r h(x) ].

Approaches that fail
There are several approaches that may appear to solve this problem, but turn out to be inadequate: 1. Supervised learning. We could learn a regressor s : X × A → [0, 1] which is trained to predict the reward, on observed events conditioned on the action a and other information x. From this regressor, a policy is derived according to h(x) = argmax a∈A s(x, a). A flaw of this approach is that the argmax may extend over a set of choices not included in the training data, and hence may not generalize at all (or only poorly). This can be verified by considering some extreme cases. Suppose that there are two actions a and b with action a occurring 10 6 times and action b occuring 10 2 times. Since action b occurs only a 10 −4 fraction of the time, a learning algorithm forced to trade off between predicting the expected value of r a and r b overwhelmingly prefers to estimate r a well at the expense of accurate estimation for r b . And yet, in application, action b may be chosen by the argmax. This problem is only worse when action b occurs zero times, as might commonly occur in exploration situations.
2. Bandit approaches. In the standard setting these approaches suffer from the curse of dimensionality, because they must be applied conditioned on X. In particular, applying them requires data linear in X × A, which is extraordinarily wasteful. In essence, this is a failure to take advantage of generalization.
3. Contextual Bandits. Existing approaches to contextual bandits such as EXP4 (Auer et al., 2002) or Epoch Greedy (Langford & Zhang, 2008), require either interaction to gather data or require knowledge of the probability the logging policy chose the action a. In our case the probability is unknown, and it may in fact always be 1.
4. Exploration Scavenging. It is possible to recover exploration information from action visitation frequency when a logging policy chooses actions independent of the input x (but possibly dependent on history) . This doesn't fit our setting, where the logging policy is surely dependent on the query.

Our Approach
Our approach naturally breaks down into three steps.
1. For each event (x, a, r a ), estimate the probabilityπ (a|x) that the logging policy chooses action a using regression.
2. For each event, create a synthetic controlled contextual bandit event according to (x, a, r a , 1/ max{π(a|x), τ }) where τ > 0 is some parameter. The fourth element in this tuple, 1/ max{π(a|x), τ }, is an importance weight that specifies how important the current event is for training. The parameter τ may appear mysterious at first, but is critical for numeric stability.
3. Apply an offline contextual bandit algorithm to the set of synthetic contextual bandit events. In our experimental results a variant of the argmax regressor is used with two critical modifications: (a) We limit the scope of the argmax to those actions with positive probability. (b) We importance weight events so that the training process emphasizes good estimation for each action equally.
It should be emphasized that the theoretical analysis in this paper applies to any algorithm for learning on contextual bandit events-we chose this one because it is a simple modification on existing (but fundamentally broken) approaches.
Three critical questions arise when considering this approach.
1. What doesπ(a|x) mean, given that the logging policy may be deterministically choosing an action (ad) a given features x? The essential observation is that a policy which deterministically chooses action a on day 1 and then deterministically chooses action b on day 2 can be treated as randomizing between actions a and b with probability 0.5 when the number of events is the same each day, and the events are IID. Thusπ(a|x) is an estimate of the expected frequency with which action a would be displayed given features x over the timespan of the logged events. In section 3 we show that this approach is sound in the sense that in expectation it provides an unbiased estimate of the value of new policy.
2. How do the inevitable errors inπ(a|x) influence the process? It turns out they have an effect which is dependent on τ . For very small values of τ , the estimates ofπ(a|x) must be extremely accurate to yield good performance while for larger values of τ less accuracy is required. In Section 3.1, we prove this robustness property.
3. What influence does the parameter τ have on the final result? While creating a bias in the estimation process, it turns out that the form of this bias is mild and relatively reasonable-actions which are displayed with low frequency conditioned on x effectively have an underestimated value. This is exactly as expected for the limit where actions have no frequency. In section 3.1 we prove this.
We close with a generalization from policy evaluation to policy selection with a sample complexity bound in section 3.2 and then experimental results in section 4 using a real ad dataset.

Formal Problem Setup and Assumptions
Let π 1 , ..., π T be T policies, where, for each t, π t is a function mapping an input from X to a (possibly deterministic) distribution over A. The learning algorithm is given a dataset of T samples, each of the form (x, a, r a ) ∈ X × A × [0, 1], where (x, r) is drawn from D as described in Section 1, and the action a ∼ π t (x) is chosen according to the tth policy. We denote this random process by (x, a, r a ) ∼ (D, π t (·|x)). Similarly, interaction with the T policies results in a sequence S of T samples, which we denote S ∼ (D, π t (·|x)) T t=1 . The learner is not given prior knowledge of the π t .

Offline policy estimator
Given a dataset of the form where ∀t, x t ∈ X, a t ∈ A, r t,at ∈ [0, 1], we form a predictorπ : X × A → [0, 1] and then use it with a threshold τ ∈ [0, 1] to form an offline estimator for the value of a policy h.
Formally, given a new policy h : X → A and a dataset S, define the estimator: where I(·) denotes the indicator function.
The purpose of τ is to upper bound the individual terms in the sum and is similar to previous methods (Owen & Zhou, 1998).

Theoretical Results
We now present our algorithm and main theoretical results. The main idea is twofold: first, we have a policy estimation step, where we estimate the (unknown) logging policy (analyzed in Subsection 3.1); second, we have a policy optimization step, where our we utilize our estimated logging policy (analyzed in Subsection 3.2). Our main result, Theorem 3.2, provides a generalization bound -addressing the issue of how both the estimation and optimization error contribute to the total error.
The logging policy π t may be deterministic, implying that conventional approaches relying on randomization in the logging policy are not applicable. We show next that this is ok when the world is IID and the policy varies over its actions. We effectively substitute the standard approach of randomization in the algorithm for randomization in the world.
A basic claim is that the estimator is expectation equivalent to a stochastic policy defined as follows: where UNIF(· · · ) denotes the uniform distribution. The stochastic policy π chooses an action uniformly at random over the T policies π t . Our first result is that the expected value of our estimator is the same when the world chooses actions according to either π or to the sequence of policies π t . Although this result and its proof are straight-forward, it forms the basis for the rest of the results in our paper. Note that the policies π t may be arbitrary but we have assumed that they do not depend on the data used for evaluation. Allowing for the offline evaluation of policies using the same data they are trained on is an important open problem.
Theorem 3.1. For any contextual bandit problem D with identical draws over T rounds, for any sequence of possibly stochastic policies π t (a|x) with π derived as above, and for any predictorπ, This theorem relates the expected value of our estimator when T policies are used to the much simpler and more standard setting where a single fixed stochastic policy is used. Proof.
Each equality follows form linearity of expectation, relabeling, or the definition of expectation. The identical draws assumption is used in 6th equality.

Policy Estimation
In this section we show that for a suitable choice of τ andπ our estimator is sufficiently accurate for evaluating new policies h. We aggressively use the simplification of the previous section, which shows that we can think of the data as generated by a fixed stochastic policy π, i.e. π t = π for all t.
For a given estimateπ of π define the "regret" to be a function reg : X → [0, 1] by Our first result is that the new estimator is consistent. In the following theorem statement, I(·) denotes the indicator function, π(a|x) the probability that the logging policy chooses action a on input x, andV ĥ π our estimator as defined by Equation 2 based on parameter τ .
Lemma 3.1. Letπ be any function from X to distributions over actions A. Let h : X → A be any deterministic policy. Let V h (x) = E r∼D(·|x) [r h(x) ] denote the expected value of executing policy h on input x. We have that In the above, the expectation E[V ĥ π ] is taken over all sequences of T tuples (x, a, r) where (x, r) ∼ D and a ∼ π(·|x). 1 This lemma bounds the bias in our estimate of V h (x). There are two sources of bias-one from the error of π(a|x) in estimating π(a|x), and the other from threshold τ . For the first source, it's crucial that we analyze the result in terms of the squared loss rather than (say) ℓ ∞ loss, as reasonable sample complexity bounds on the regret of squared loss estimates are achievable.
Proof. Consider a fixed x. Define the following quantity The quantity δ x is the error of our estimator conditioned on x and satisfies E We consider two disjoint cases.
First, suppose that π(h(x)|x) < τ . Then, δ x is less than or equal to zero, due to the max operation in the denominator and the fact that rewards are positive. Thus, we have that E[V ĥ π ] ≤ V h , when the expectation is taken over the x for which π(h(x)|x) < τ . As an aside, note that |δ x | can have magnitude as large as 1. In other words, in this situation, the estimator may drastically underestimate the value of policy h but will never overestimate it.
Second, suppose that π(h(x)|x) ≥ τ . Then, we have that Expanding δ x and taking the expectation over x for which π(h(x)|x) ≥ τ yields the desired result.
Corollary 3.1. Letπ be any function from X to distributions over actions A. Let h : X → A be any deterministic policy. If π(h(x)|x) ≥ τ for all inputs x, then Proof. Follows from examining the second part of the proof of Lemma 3.1 and applying Jensen's inequality.
Lemma 3.1 shows that the expected value of our esti-mateV h π of a policy h is an approximation to a lower bound of the true value of the policy h where the approximation is due to errors in the estimateπ and the lower bound is due to the threshold τ . Whenπ = π, then the statement of Lemma 3.1 simplifies to Thus, with a perfect predictor of π, the expected value of the estimatorV ĥ π is a guaranteed lower bound on the true value of policy h. However, as the left-handside of this statement suggests, it may be a very loose bound, especially if the action chosen by h often has a small probability of being chosen by π.

Policy Optimization
The previous section proves that we can effectively evaluate a policy h by observing a stochastic policy π, as long as the actions chosen by h have adequate support under π, specifically π(h(x)|x) ≥ τ for all inputs x. However, we are often interested in choosing the best policy h from a set of policies H after observing logged data. Furthermore, as described in Section 2, the logged data are generated from T fixed, possibly deterministic, policies π 1 , . . . , π T as described in section 2 rather than a single stochastic policy. As in Section 3 we define the stochastic policy π by Equation 3, π(a|x) = E t∼UNIF(1,...,T ) [π t (a|x)] The results of Section 3.1 apply to the policy optimization problem. However, note that the data are now assumed to be drawn from the execution of a sequence of T policies π 1 , . . . , π T , rather than by T draws from π.
Next, we show that it is possible to compete well with the best hypothesis in H that has adequate support under π (even though the data are not generated from π).
Theorem 3.2. Letπ be any function from X to distributions over actions A. Let H be any set of deterministic policies. DefineH = {h ∈ H | π(h(x)|x) > τ, ∀ x ∈ X} andh = argmax h∈H {V h }. Letĥ = argmax h∈H {V ĥ π } be the hypothesis that maximizes the empirical value estimator defined in Equation 2. Then, with probability at least 1 − δ, where reg(x) is defined, with respect to π, in Equation 5.
Proof. First, given a dataset (x t , a t , r t,at ), t = 1, . . . , T , generated by the process described in Section 2, note that it is straight-forward to apply Hoeffding's bound (Hoeffding, 1963) to the random variables holds with probability at least 1 − δ, for a fixed policy h. It is important to note here that the X t are independent but not identical, since the action at time t is chosen according to policy π t . The previous argument can be made to hold for all h ∈ H by replacing δ with δ/|H| and applying the union bound.
Let Q = (D, π t (·|x)) T t=1 be the distribution over sequences of T samples (x, a, r a ) ∈ X × A × [0, 1] generated by executing the T logging policies π t in sequence, as described in section 2. Let Q ′ = (D, a ∼ π(·|x)) be the distribution over samples of the form (x, a, r a ) ∈ X × A × [0, 1] such that (x, r) ∼ D and a ∼ π(·|x). The T samples used in the estimatorV h π are obtained from a single draw from Q.

Now, we have that
Vĥ The first step follows from Lemma 3.1. The second from the fact that regret is always non-negative. The third from an application of Jensen's inequality. The forth and eighth from an application of Theorem 3.1. The fifth and seventh from an application of Hoeffding's bound as detailed above. The sixth from the definition ofh. The final step follows from Corollary 3.1 and observing thath ∈H.
The proof of Theorem 3.2 relies on the lower-bound property of our estimator (the left-hand side of Inequality stated in Lemma 3.1). In other words, if H contains a very good policy that has little support under π, we will not be able to detect that by our estimator. On the other hand, our estimation is safe in the sense that we will never drastically overestimate the value of any policy in H. This "underestimate, but don't overestimate" property is critical to the application of optimization techniques, as it implies we can use an unrestrained learning algorithm to derive a warm start policy.

Empirical Evaluation
We evaluated our method on a real-world Internet advertising dataset. We have obtained proprietary data from an online advertising company, covering a period of approximately one month. The data are comprised of logs of events (x, a, y), where each event represents a visit by a user to a particular web page x, from a set of web pages X. From a large set of advertisements A, the commercial system chooses a single ad a for the topmost, or most prominent position. It also chooses additional ads to display, but these were ignored in our test. The output y is an indicator of whether the user clicked on the ad or not.
The total number of ads in the data set is approximately 880, 000. The training data consist of 35 million events. The test data contain 19 million events occurring after the events in the training data. The total number of distinct web pages is approximately 3.4 million.
We trained a policy h to choose an ad, based on the current page, to maximize the probability of click. For the purposes of learning, each ad and page was represented internally as a sparse high-dimensional feature vector. The features correspond to the words that appear in the page or ad, weighted by the frequency with which they appear. Each ad contains, on average, 30 ad features and each page, approximately 50 page features. The particular form of f was linear over all features of its input (x, y), which is a sparse high-dimensional feature vector representing the combination of the page and ad. 2 For instance, every pair of possible words had a corresponding feature. For example, given the two words "apple" and "ipod", the corresponding feature "apple-ipod" has a value of 0.25 when the first word, "apple", appeared in the page x with frequency 0.5 and the second word, "ipod", appeared in the ad a with frequency 0.5.
Using all the data, we modeled the logging policy using simple empirical estimation: In words, for each page and ad pair (x, a), we computed the number of times a appeared on page x in the data. The decision to use all of the data requires careful consideration. Some alternatives to consider are: 1. Training data only. Since the set of ads changes over time, many ads appearing in the test data do not occur at all in the training data. Consequently, reliably predicting the performance on test data is problematic.
2. Training data for training set and test data for test set. This approach has an inherent bias to-wards incorrectly high scores on the test set. In an extreme case, suppose that only one ad appears on a (rare) webpage in the test set. Then, any policy selecting from amongst the set of appearing ads must select this ad.
3. All data. This approach means that policies must generally select from a larger set of ads than are available at any moment in time for the live system, implying that the policy evaluation is generally pessimistic. Note that the logging policy in contrast is optimistically evaluated, because the set of test-time available ads is smaller than the set of ads available over both test-time and traintime ads, implying the frequency estimates for test-time ads on the train+test dataset are generally smaller than an estimate using just test-time ads. 3 These smaller-than-necessary frequency estimates imply that the logging policy evaluation is optimistic since events are weighted by the inverse frequency. Consequently, this choice provides a conservative estimate for new policies and an optimistic choice for the older (logging) policy.
The particular policy that was optimized, had an argmax form: h(x) = argmax a∈C(X) {f (x, a)}, with a crucial distinction from previous approaches in how f (x, a) was trained. Here f : X ×A → [0, 1] is a regression function that is trained to estimate probability of click, and C(X) = {a ∈ A |π(a|x) > 0} is a set of feasible ads.
The training samples were of the form (x, a, y), where y = 1 if the ad a was clicked after being shown on page x or y = 0 if it wasn't clicked. The regressor f was chosen to approximately minimize the weighted squared loss: (y−f (x,a)) 2 max{π(at|xt),τ } . Stochastic gradient descent was used to minimize the squared loss on the training data.
During the evaluation, we computed the estimator on 3 As an extreme example, suppose we log data for two days and we use the first day for training and the second day for testing. Suppose that only a single ad a1 appears in the train set, and a single ad a2 appears in the test set, due to the fact that the budget for ad a1 ran out after the first day. Our empirical estimate ofπ(a2|x) on the test set used in the denominator of our estimator (Equation 8) will be 1/2. In fact the true probability of a2 on the test set is 1. Thus, the value of the logging policy will be over estimated by a factor of 2. Suppose further that ad a1 is indeed better than a2. The evaluation of a policy that always chooses the better ad, a1, using Equation 8 will be zero, a drastic underestimate of its true value. the test data (x t , a t , y t ): As mentioned in the introduction, this estimator is biased due to the use of the parameter τ > 0. As shown in the analysis of Section 3, this bias typically results in an underestimate of the true value of the policy h.
We experimented with different thresholds τ and parameters of our learning algorithm. 4 The Interval column is computed using the relative entropy form of the Chernoff bound with δ = 0.05 which holds under the assumption that variables, in our case the samples used in the computation of the estimator (Equation 9), are IID. Note that this computation is slightly complicated because the range of the variables is [0, 1/τ ] rather than [0, 1] as is typical. This is handled by rescaling by τ , applying the bound, and then rescaling the results by 1/τ .

Method
The "Random" policy is the policy that chooses randomly from the set of feasible ads: Random(x) = a ∼ UNIF(C(X)), where UNIF(·) denotes the uniform distribution.
The "Naive" policy corresponds to the theoretically flawed supervised learning approach detailed in the introduction. The evaluation of this policy is quite expensive, requiring one evaluation per ad per example, so the size of the test set is reduced to 8373 examples with a click, which reduces the significance of the results. We bias the results towards the naive policy by choosing the chronologically first events in the test set (i.e. the events most similar to those in the training set). Nevertheless, the naive policy receives 0 reward, which is significantly less than all other approaches. A possible fear with the evaluation here is that the naive policy is always finding good ads that simply weren't explored. A quick check shows that this is not correctthe naive argmax simply makes implausible choices.
Note that we report only evaluation against τ = 0.05, as the evaluation against τ = 0.01 is not significant, although the reward obviously remains 0.
The "Learned" policies do depend on τ . As suggested by Theorem 3.2, as τ is decreased, the effective set of hypotheses we compete with is increased, thus allowing for better performance of the learned policy. Indeed, the estimates for both the learned policy and the random policy improve when we decrease τ from 0.05 to 0.01.
The empirical click-through rate on the test set was 0.0213, which is slightly larger than the estimate for the best learned policy. However, this number is not directly comparable since the estimator provides a lower bound on the true value of the policy due to the bias introduced by a nonzero τ and because any deployed policy chooses from only the set of ads which are available to display rather than the set of all ads which might have been displayable at other points in time.
The empirical results are generally consistent with the theoretical approach outlined here-they provide a consistently pessimal estimate of policy value which nevertheless has sufficient dynamic range to distinguish learned policies from random policies, learned policies over larger spaces (smaller τ ) from smaller spaces (larger τ ), and the theoretically unsound naive approach from sounder approaches which choose amongst the the explored space of ads.

Conclusion
We stated, justified, and evaluated theoretically and empirically the first method for solving the warm start problem for exploration from logged data with controlled bias and estimation. This problem is of obvious interest to applications for internet companies that recommend content (such as ads, search results, news stories, etc...) to users.
However, we believe this also may be of interest for other application domains within machine learning. For example, in reinforcement learning, the standard approach to offline policy evaluation is based on importance weighted samples (Kearns et al., 2000;Precup et al., 2000). The basic results stated here could be applied to RL settings, eliminating the need to know the probability of a chosen action explicitly, allowing an RL agent to learn from external observations of other agents.
The main restrictive assumption adopted by the Exploration Scavenging paper  is that the logging policy chooses actions independently of the input. We have introduced a new method that works when this assumption is violated. On the other hand, we have required the logging policy be a sequence of fixed, possibly deterministic, policies, whereas the Exploration Scavenging paper allowed for the use of logging policies that learn and adapt over time. An interesting situation occurs when you allow π t to depend on the history up to time t. In this setting the policy may both adapt (like in the Exploration Scavenging paper) and choose actions dependent on the current input. Is there an offline policy estimator which can work in this setting?
The most generic answer is no, but there may exist some natural constraint which encapsulates the approach discussed here, as well as in the earlier paper.