Defining Cohort and Label recipes#
A good resource here is the Deep Dive in Triage Documentation.
Key idea#
The cohort and labels query takes two parameters ({as_of_date} and {label_timespan}) and returns two columns: entity_id (of type int) and outcome (of type int). For a given {as_of_date}, the list of entity_ids is the cohort that is active (available to be scored/classified/ranked/predicted) on that date, and the outcome is the label for that entity to be used by the ML model for training and validation. The outcome can be 0,1, or NULL (where the label is unknown). There is an optional parameter that comes after the query that can specify to ignore the NULL values or to treat them as 0s.
Cohort is every entity in the data, and label is 1 if a specific event happens in the next year and 0 otherwise.#
label=1 if a specific event happens in the next year is controlled by
temporal_config:
label_timespans: ['1year']
label_config:
query: |
select
entity_id,
case
when (event_date >= '{as_of_date}'::date
and
event_date < '{as_of_date}'::date + interval '{label_timespan}')
then 1
else 0
end as outcome
from entities left join events using(entity_id)
name: 'anyeventfuture'