liveBook · Manning

Context

As explained in Experimentation for Engineers

The observed information about a user that conditions which action a contextual bandit selects.

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

How Experimentation for Engineers covers it

How deep it goes
Defines context as a feature vector and uses it in a simulated reward function, without detailing feature engineering.
Examples
Uses age, ZIP code, reported interests, app-use frequency, posts, and viewing time as concrete examples.
What you can do after
Apply it via a reward simulator by encoding user information as a feature vector.
How it connects
Connects context to contextual bandits, actions, rewards, and reward-prediction models.

Also explained in

Compare how 18 books explain context →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Experimentation for Engineers. The section links point to the parts of the book it draws on.