Realtime and predictive cohorts
Add people to a cohort the moment their event arrives (realtime), or keep the people most likely to convert or spend in a cohort (predictive), with the options and API routes.
Both build on ordinary cohorts. See Cohorts and actions over the API for the criteria tree.
Realtime cohorts
A dynamic cohort recalculates every 15 minutes. With realtime: true, the worker also adds a person as soon as one ingested event proves they qualify, without waiting for the next recalculation.
curl -X POST https://<app host>/v1/projects/$PROJECT/cohorts \
-H "Authorization: Bearer $LUCIDA_KEY" -H "Content-Type: application/json" \
-d '{"name":"Started checkout","kind":"dynamic","realtime":true,
"filters":{"type":"and","values":[{"type":"performed","event":"checkout_started","window":{"days":7}}]}}'You can also turn it on or off later with PATCH /v1/projects/{project_id}/cohorts/{id} and {"realtime": true}.
A definition is realtime-eligible only when it is an and/or tree made of:
performedwith an event name, optional property filters, "at least once" (nocount, orgte 1/gt 0) and awindowin days; andperson_propertyfilters that all useeq.
An and needs every child satisfied by the same event; an or needs one. Anything else (counts above one, sequences, not_performed, in_cohort, lifecycle, other operators, saved actions, fixed date windows) is rejected with 400 when you turn realtime on.
Realtime only adds. People who age out of the window or whose property changes are removed by the 15-minute job, which stays the source of truth. If a realtime add fails it is logged and the job still catches the person.
Predictive cohorts
A predictive cohort trains a small explainable model (L2-regularised logistic regression on ln(1 + count) of recent events) that predicts whether a person does a goal event within a horizon, and keeps the highest-scoring people in a static cohort.
Field | Meaning |
|---|---|
| The cohort name and the event to predict |
| 1 to 20 event names whose recent counts are the inputs |
|
|
| History behind each count, 1 to 180, default 30 |
| Predict the goal within this many days, 1 to 90, default 7 |
|
|
|
|
| 1 to 8760; leave out to retrain only on request |
| Count the schedule from the last |
| Seeds the training sample and the holdout split, default 0 |
|
|
| For |
Training needs at least 50 people, with at least 5 who reached the goal and 5 who did not. With less, POST answers 422 and nothing is created. A quarter of the data is held out; the response carries the holdout auc, a calibration table, row counts, the base rate and the model weights per feature. A revenue model adds a mean absolute error and predicted-versus-actual revenue by decile. cohort_id is the static cohort that holds the selected people, usable anywhere a cohort is (insights, flags, destinations).
Routes (all under /v1/projects/{project_id}):
Route | What it does |
|---|---|
| List, create (and train) |
| Read, with |
| Change |
| Train and score now |
| Remove |
In the app, the same form is under Predictive cohorts.