LeveredDocs
Concepts

Context Factors

User and session attributes that the model uses to select a variant per user segment.

Context factors are attributes of the user or the session, for example country or device type. The model uses them to select a variant for each user segment. The variant itself is defined by design factors.

Context factors are optional. They are defined on the optimization with --context-factors on levered optimizations create. Every optimization uses the same model. If the optimization has context factors and the app passes context values, the model uses them. Without context factors, the model selects variants in the same way for all users.

How context factors work

The model estimates the probability of a reward for each combination of context values and variant:

P(reward | context, variant)

Example: country is a context factor and headline is a design factor. The model can learn the following from the logged exposures and rewards:

  • Users with country = "DE" convert best with headline = "Kostenlos starten".
  • Users with country = "US" convert best with headline = "Boost your revenue".

Defining context factors

A context factor has the following properties:

PropertyDescription
NameAn identifier such as country, device_type or traffic_source.
Data typestr or bool.
LevelsThe values that the factor can take. Define one level for each user segment that occurs in the data.

Examples:

Context factorTypeLevels
countrystr"US", "DE", "UK", "FR"
device_typestr"desktop", "mobile", "tablet"
is_returning_userbooltrue, false

Pass the context values of the current user with each variant request to the SDK or the API. The model uses these values to select the variant.

When to use context factors

Use context factors if the best variant is expected to differ between user segments. Common context factors:

  • Geography. Markets can respond differently to the same messaging.
  • Device type. Mobile users can prefer shorter headlines or a different layout.
  • Traffic source. Users from paid ads can have a different intent than organic visitors.
  • User segment. For example new and returning users, or free and paid tier.

If the best variant is not expected to differ between segments, do not define context factors. The model then needs less data to converge.

Limits

  • Data volume. Each context factor divides the users into more segments. With country (4 levels) and device_type (3 levels), the model learns across 12 segments. Each segment needs enough observations for a reliable estimate.
  • Relevance. Add a context factor if there is a hypothesis that the best variant differs across its levels. A context factor without an effect slows convergence and does not improve the result.
  • Predefined levels. The levels are defined when the optimization is created. Fields with many distinct values, such as a user id or a session id, cannot be used directly. Group them into categories first.
  • Missing values. If a request contains no value for a context factor, the model uses its estimate across all users.

Context factors and design factors

Design factorsContext factors
RepresentThe variant that the user seesAttributes of the user or the session
Value comes fromLevered, which assigns the variantThe app, which passes the observed value
RequiredYesNo
Effect on the modelThe model learns the reward of each variantThe model learns the reward of each variant per segment
Exampleheadline, cta_text, layoutcountry, device_type, is_new_user