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
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.
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:
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
}
]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 Sizeof 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}}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:
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.
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.
Verify
clustering_cohortappears onUserPointin the published schema, and a lookalike can be created from a seed segment.
Troubleshooting
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.
Related pages
Last updated
Was this helpful?