For the complete documentation index, see llms.txt. This page is also available as Markdown.

Cohort-based Lookalike

Configure the cohort model a datamart needs before anyone can build a cohort lookalike segment.

Your goal

Set up the cohort model once per organisation, so your teams can build cohort lookalike segments from a seed segment.

Expected outcome

clustering_cohort appears on UserPoint in the published schema, and a lookalike can be created from a seed segment.

Before you start

Cohort-based Lookalike is not enabled by default. Contact your Account Manager to enable it.

The cohort model assigns every user a cohort from the attributes you chose to characterise your user base. It has to exist on the datamart before anyone can build a cohort lookalike segment, and its attributes are an organisation-level decision rather than a per-segment one.

Set it up

The steps below have to be performed in this order.

1

Define the attributes

A cohort is assigned to a user according to the attributes - features, in data-science terms - you have defined to characterise your users. You declare them as JSON.

These attribute types are available:

Type
Use it for
How the values are declared

FREQUENCY_ENUM

A finite list of values, such as operating systems.

values: the list itself.

FREQUENCY_NUMBER

Number buckets, such as age.

intervals: from inclusive, to exclusive. Anything outside the declared intervals falls into an extra bucket.

FREQUENCY_TEXT

An infinite or very long list of values, such as keywords or cities.

vector_size: used as a modulo on the values, to reduce their disparity to a fixed number. Choose it carefully.

field_path is the path of the attribute from the UserPoint definition in your schema.

Cohorts built on os_family (on UserAgentInfo, nested in UserAgent), age (on UserProfile) and city (on UserEvent) are declared like this:

[
  {
    "type": "FREQUENCY_ENUM",
    "field_path": "agents.user_agent_info.os_family",
    "values": [
      "OTHER",
      "WINDOWS",
      "MAC_OS",
      "LINUX",
      "ANDROID",
      "IOS"
    ]
  },
  {
    "type": "FREQUENCY_NUMBER",
    "field_path": "profiles.age",
    "intervals": [
      {
        "from": 0,
        "to": 10
      },
      {
        "from": 10,
        "to": 100
      }
    ]
  },
  {
    "type": "FREQUENCY_TEXT",
    "field_path": "events.city",
    "vector_size": 100
  }
]

How the number buckets above read. First bucket: age >= 0 and age < 10. Second bucket: age >= 10 and age < 100. Third bucket: everything that fell into neither.

Recommendations for the selection itself:

  • Pick attributes that can be used to segment users and that are relevant to the business.

  • Pick attributes available on all your users, logged in and logged out.

  • Pick attributes from various typologies: UserEvent, UserProfile, and so on.

  • Select between 3 and 10 attributes, carrying between 50 and 300 values in total.

  • Keep the default of 1024 cohorts, which is a Cohort Id Bit Size of 10.

The function also needs the GraphQL query that fetches exactly those fields. For the attributes above:

{agents {user_agent_info {os_family}} profiles {age} events{city}}
2

Create the ML Function

Go to Settings > Datamart > ML Functions and click New Ml Function, pick the datamart the function applies to, then choose the simhash-cohorts-calulation algorithm. Fill the configuration panel with:

Field
Value

Name

Cohort ML Function

Hosting Object Type

UserPoint

Field Type Name

ClusteringCohort

Field Name

clustering_cohort

Query

The GraphQL query from the previous step.

Properties > Features

The attributes JSON from the previous step, on one line.

Properties > Cohort Id Bit Size

Sets the number of cohorts in your datamart, as 2^(Cohort Id Bit Size).

Then save.

3

Activate it

Set batch_mode to true and the status to ACTIVE:

PUT https://api.mediarithmics.com/v1/ml_functions/<ml_function_id>
{
  "batch_mode": true,
  "status": "ACTIVE"
}
4

Update the schema

Make these changes in your runtime schema. Add a clustering_cohort field on UserPoint:

type UserPoint  @TreeIndexRoot(index:"USER_INDEX") {
   ...
   clustering_cohort:ClusteringCohort
   ...
}

And create the ClusteringCohort type:

type ClusteringCohort  {
   id:ID! @TreeIndex(index:"USER_INDEX")
   expiration_ts:Timestamp @TreeIndex(index:"USER_INDEX")
   cohort_id:String! @TreeIndex(index:"USER_INDEX")
   last_modified_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
}

See Schema definition for how a schema change is published.

5

Ask for the initial loading

Cohorts on your existing UserPoints are calculated by an initial loading, which the mediarithmics team runs on your datamart. Ask your Account Manager for it once the steps above are done.

Verify

  • clustering_cohort appears on UserPoint in the published schema, and a lookalike can be created from a seed segment.

Troubleshooting

Symptom
Likely cause

Cohorts are missing on users who existed before the model

The initial loading has not run. It is triggered by the mediarithmics team: ask your Account Manager.

Last updated

Was this helpful?