Context is the observed information about a user that conditions a contextual bandit’s action. In a post-selection system, the model predicts viewing time from the user and candidate post: viewing time = f(user, post). section 5.1.1
A context vector can contain:
- Demographics such as age and ZIP code. section 5.1.1
- Reported interests, app-use frequency, and other user-designed features. section 5.1.1
- The inputs used to estimate the reward produced by each possible action. section 5.1.1
Post selection
When a user opens the app, the server receives the user’s context and selects one post. Longer viewing time represents a better reward for that context-dependent action. section 5.1.1
Listing 5.1 Simulate viewing time
def measure_viewing_time(context, action_weights):
return np.exp( (context*action_weights).mean() #1
+ 0.1*np.random.normal()) #2
A small simulator makes the context–action relationship concrete by combining context features with action weights and random variation. section 5.1.1

















