:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(autoresearch): add working-with-autoresearch skill for users and agents (#115793)
Andrew Maguire357d2622092a
diff --git a/products/autoresearch/skills/working-with-autoresearch/SKILL.md b/products/autoresearch/skills/working-with-autoresearch/SKILL.mdnew file mode 100644index 000000000000..912c94703bee--- /dev/null+++ b/products/autoresearch/skills/working-with-autoresearch/SKILL.md@@ -0,0 +1,96 @@+---+name: working-with-autoresearch+description: >+ Use PostHog Autoresearch, agent-driven predictive models: ask "who will do X in the next N days?",+ let an agent train a model, then score people daily into a person property and+ `autoresearch_prediction` events. Use when a user wants to predict churn, activity, return,+ feature adoption, conversion or any event or action per person; create or validate a model from a+ template; start training or score now; read model quality (holdout vs realized AUC, lift,+ calibration, likelihood segments, coverage); steer training with suggestions; act on predictions+ with cohorts, feature flags, workflows or SQL; or diagnose a model that fails to train, scores+ everyone the same, or stops scoring. Trigger on "autoresearch", "predictive model", "propensity+ score", "churn prediction", "likely to convert", "who will do X", "predicted_p_",+ "autoresearch_prediction", "realized AUC", "champion model".+---++# Working with autoresearch++Autoresearch answers one standing question per model: **who in a population will do a target within a horizon?**+For example, "which active users will open a report in the next 7 days?".++1. The user names a **target** (an event or a PostHog action), a **population** and a **horizon** in days.+2. A training agent runs in a PostHog sandbox. It writes feature SQL and a model, scores each experiment on a holdout set, keeps what improves holdout AUC and discards the rest.+3. The server picks the **champion** from the kept experiments. The agent proposes; the backend decides.+4. Every cadence (daily by default, at 02:00 UTC), the champion scores the inference population.+ Each scored person gets an `autoresearch_prediction` event with their probability.+ A person who resolves to a current distinct ID also gets the model's output person property, for example `predicted_p_adopt_insights_14d`.+5. When a prediction date's horizon has passed, online validation checks the scores against what really happened and records **realized AUC**.++In the PostHog UI the entity is a **model**. The API and tools call it a **pipeline**. Use "model" when you talk to people.++Autoresearch is behind the `autoresearch` feature flag.+Training runs in a cloud sandbox, so it also needs PostHog Desktop access.+If the `autoresearch-*` tools are missing, the project probably does not have access yet.++## Pick the job++| The user wants to | Start with | Reference |+| --------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |+| Create a model | `posthog:autoresearch-resolve-template-create` or a custom definition, then `posthog:autoresearch-validate-create` | [defining-a-question.md](references/defining-a-question.md) |+| Know if a model is any good | `posthog:autoresearch-retrieve`, then `posthog:autoresearch-online-performance-retrieve` | [reading-model-quality.md](references/reading-model-quality.md) |+| Use the predictions | The output person property, or `posthog:execute-sql` on `autoresearch_prediction` | [using-predictions.md](references/using-predictions.md) |+| Fix or steer a model | `posthog:autoresearch-training-runs-list`, `posthog:autoresearch-runs-list`, `posthog:autoresearch-suggestions-create` | [troubleshooting-and-steering.md](references/troubleshooting-and-steering.md) |+| See what models exist | `posthog:autoresearch-list` | This page |++## Create, train, score++The usual path is short. Each tool's description names its prerequisites and refusals, so read it with `info` before the first call.++1. **Resolve or define.** Templates cover the common questions (activity, inactivity risk, return after first use, feature adoption, repeat behavior). A custom definition works when none fits. See [defining-a-question.md](references/defining-a-question.md).+2. **Validate.** `posthog:autoresearch-validate-create` with the same target, horizon, lookback and populations you will create with. It returns the base rate, positive and negative counts and warnings. Fix anything that sets `can_proceed` to false, and tell the user about the non-blocking warnings.+3. **Create.** `posthog:autoresearch-create`. The new model is a `draft` until training starts.+4. **Train.** `posthog:autoresearch-train-create` starts an agent run that takes a while (often tens of minutes). It costs real sandbox and LLM time, so confirm with the user before you start one, and never start a second run while one is live. A 403 means either the call came from inside a sandbox (ask the user to click **Start training** on the model's page) or the user has no PostHog Desktop access (the page will refuse too). Read the error message to tell them apart.+5. **Wait.** Poll `posthog:autoresearch-training-runs-list` at a relaxed pace. While the first run is in progress the model is `bootstrapping`, and a missing champion is normal.+6. **Score.** After a champion is promoted, the next daily sweep scores the population. `posthog:autoresearch-score-create` scores today now; call it once, then poll `posthog:autoresearch-runs-list`. A second manual score for the same date can duplicate predictions.++Pause, resume and delete are in the model's menu in the UI only.+Pausing stops scoring and new training runs. A training run already in progress keeps running, and it can still promote a champion.++## Model status++| Status | Meaning |+| --------------- | ------------------------------------------------------------------------------------------------------ |+| `draft` | Defined, never trained. |+| `bootstrapping` | The first training run is in progress. No champion yet. |+| `running` | A champion exists and scores on the cadence. Retraining can still happen. |+| `converged` | Treated like `running`: the champion still scores and is still validated. |+| `paused` | No scoring and no new training until someone resumes it in the UI. A run already in progress finishes. |++The training run's `iteration_count` and `best_holdout_score` are written only when the run completes.+A healthy run can show 0 iterations while its experiments are already recorded, so do not call a run stuck from the counter alone.++## How to talk about results++- **Holdout AUC** is the score on held-back training data. It says how well the model ranked people in the past. Treat it as a promise.+- **Realized AUC** is the score against real outcomes after the horizon passes. Treat it as the proof. It wins over holdout AUC whenever it exists.+- The UI labels quality **Strong** at AUC 0.8 and up, **Fair** at 0.7 and up, and **Weak** below that, and says whether the label comes from testing only or is confirmed by real outcomes. Use the same words so the agent and the UI agree.+- **Lift at 10%** is the plain-language headline: "the top 10% are 3.2× more likely to do X than average".+- The score is a probability, but on a rare target it is often best read as a ranking. Say so when the base rate is below a few percent.++[reading-model-quality.md](references/reading-model-quality.md) covers calibration, likelihood segments, coverage and what to say when the numbers disagree.++## Guardrails worth keeping in mind++- **Changing the question means a new model.** The fields a model was trained on (target, horizon, populations) are frozen once a model exists. Create a new model rather than editing one.+- **Autoresearch trains on identified users only.** Anonymous traffic does not count toward training data, so raw event volume can overstate what is available. Trust the validation counts.+- **Scores are keyed on the person.** A model whose scores are almost all the same value usually has an identifier problem, not a weak signal. See [troubleshooting-and-steering.md](references/troubleshooting-and-steering.md).+- **Read the output property name, do not guess it.** Take `output_person_property` from `posthog:autoresearch-retrieve`. A derived name includes the target and the horizon (`predicted_p_<target>_<horizon>d`), and templates use their own prefix, so two models on one target do not overwrite each other.+- **A model costs money to train and query to score.** A very large population scores in rolling batches (about 45,000 people per run), so not everyone gets a fresh score every day. Validation tells you how many runs a full rescore takes.++## Bring your own agent++An agent outside PostHog (on a laptop, for example) can train a model for an existing pipeline.+It opens a run with `posthog:autoresearch-training-runs-create`, records each experiment with `posthog:autoresearch-training-runs-iterations-create`, uploads its bundle with `posthog:autoresearch-training-runs-artifacts-upload-create`, and finishes with `posthog:autoresearch-training-runs-complete-create`.+It pulls training data with `posthog:execute-sql`, because `posthog:autoresearch-materialize-features` writes only into a PostHog sandbox.+Read `posthog:autoresearch-training-runs-history` first to reuse what earlier runs on the same target learned.+The iteration tool's description is the contract for valid feature SQL: read it in full before the first iteration.diff --git a/products/autoresearch/skills/working-with-autoresearch/references/defining-a-question.md b/products/autoresearch/skills/working-with-autoresearch/references/defining-a-question.mdnew file mode 100644index 000000000000..0baf39154072--- /dev/null+++ b/products/autoresearch/skills/working-with-autoresearch/references/defining-a-question.md@@ -0,0 +1,92 @@+# Defining a question++A model answers "who in **population** will do **target** within **horizon** days?".+Most of a model's value is decided here, before any training. A sharp question with enough positives beats a vague one with a clever model.++## Start from what the user will do with the answer++Ask what action follows the prediction before you pick a target:++- "Reach users before they go quiet" points to an inactivity question, scored on currently active users.+- "Nudge people toward feature X" points to adoption of X, scored on active users who have not used X yet.+- "Find who is ready for a sales touch" points to a conversion event, scored on the accounts sales can contact.++The population should be the people the user can act on. The horizon should match how fast they can act. A 1-day horizon is useless to a team that runs a weekly campaign.++## Templates++`posthog:autoresearch-resolve-template-create` turns a template key and optional overrides into a full config.++| Key | Question | Target | Population | Default horizon |+| ------------------------ | ------------------------------------------ | ----------------------- | --------------------------------------- | --------------- |+| `likely_active_soon` | Which active users will be active again? | Resolved activity event | Did that event in the last 30 days | 7 days |+| `at_risk_of_inactivity` | Which active users will not be active? | Resolved activity event | Did that event in the last 60 days | 14 days |+| `return_after_first_use` | Which new users will come back? | Resolved activity event | First seen in the last 14 days | 7 days |+| `feature_adoption` | Who will use a feature for the first time? | User-supplied event | Active in 30 days, never did the target | 14 days |+| `repeat_key_behavior` | Who will do a key action again? | User-supplied event | Did the target at least once | 7 days |++- The activity templates resolve the event from the project's schema. They prefer `$pageview`, then `$screen`, then `$autocapture`, then the custom event with the most identified users. Check `resolved_activity_event` against `activity_event_alternatives`, and re-resolve with a `target_event` override if a different event means "active" for this product.+- `at_risk_of_inactivity` still predicts the probability of **activity**. The at-risk group is people with a **low** score (for example below 0.2). Explain this to the user, because the name suggests the opposite.+- `feature_adoption` and `repeat_key_behavior` need `target_event`. Confirm the event exists with `posthog:read-data-schema` first.++Templates take an event target. For an action target, build a custom definition.++## Custom definitions++Pass the same fields to `posthog:autoresearch-validate-create` and `posthog:autoresearch-create`:++| Field | Notes |+| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `target_event` or `target_definition` | An event name, or `{"type": "action", "action_id": N}` for an action (multi-step, property or autocapture matchers). With an action, `target_event` is only a label. An action target needs the `action:read` scope. |+| `horizon_days` | 1 to 365. Default 7. |+| `training_lookback_days` | 7 to 730. Default 180. Must be longer than the horizon. Longer gives more examples but includes older behavior. |+| `training_population` | Who can be a training example. `{}` means all identified users. |+| `inference_population` | Who gets scored. Defaults to the training population. Keep the two consistent unless there is a clear reason. |+| `cadence_days` | Rescore every N days. Default 1. |+| `iteration_budget` | The model's total experiment budget across all training runs. Default 50. Each scheduled retrain takes at most 10 from what remains, and a run started by hand can set its own budget. |+| `output_person_property` | Optional. Derived from the target and horizon when omitted. |++### Population shapes++A population is either a semantic kind or a list of person property filters:++```json+{ "kind": "performed_event_within_days", "event": "$pageview", "days": 30 }+{ "kind": "person_first_seen_within_days", "days": 14 }+{ "kind": "active_not_performed_target", "active_within_days": 30 }+{ "kind": "ever_performed_event", "event": "purchase" }+{ "kind": "ever_performed_target" }+{ "properties": [{ "key": "plan", "value": ["pro"], "operator": "exact", "type": "person" }] }+```++- "Ever" and "not performed" look back over the training lookback window, not all time.+- The target-relative kinds use the model's own target, so they follow an action's matcher.+- Every kind is evaluated at each training example's point in time, and at the scoring cutoff for inference. Person property filters use current values, so a filter on a property that changes often can leak the future into training.+- An unknown kind is rejected. An empty population means all identified users, which is rarely what the user meant on a large project.++## Read the validation result++`posthog:autoresearch-validate-create` is advisory: `posthog:autoresearch-create` does not block on it. Run it anyway and read every field.++Blocking errors (`can_proceed` is false):++| Code | What to do |+| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |+| `low_volume` | Under 100 people. Widen the population or lengthen the lookback. |+| `low_positives` | Under 20 people did the target. Lengthen the horizon or the lookback, or pick a more common target. |+| `low_negatives` | Under 20 people did not do the target. Shorten the horizon, pick a rarer target, or use a population with more people who do not convert. |+| `horizon_exceeds_lookback` | Raise `training_lookback_days` above `horizon_days`. |+| `population_too_large` (error) | Narrow the training population. |++Warnings to pass on:++| Code | What it means for the user |+| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |+| `extreme_imbalance` | Base rate below 1%. The model can still rank well, but probabilities are small and noisy, and realized AUC needs many days of data to settle. |+| `near_universal` | Above 95% do the target anyway. The model has little to add. Suggest a rarer target or a narrower population. |+| `population_too_large` (info) | Scoring runs in rolling batches. The message says how many runs a full rescore takes. |++## Name it as a question++Use the question as the name: "Who will invite a teammate in the next 7 days?".+The UI already shows models as questions, and the name is what people see on every card.diff --git a/products/autoresearch/skills/working-with-autoresearch/references/reading-model-quality.md b/products/autoresearch/skills/working-with-autoresearch/references/reading-model-quality.mdnew file mode 100644index 000000000000..1aa17d1dce93--- /dev/null+++ b/products/autoresearch/skills/working-with-autoresearch/references/reading-model-quality.md@@ -0,0 +1,80 @@+# Reading model quality++Quality has two stages. The model makes a promise at training time (holdout) and keeps it, or not, in production (realized).+Lead with the realized numbers when they exist, and say plainly when they do not exist yet.++## Where the numbers live++| Tool | What it gives |+| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `posthog:autoresearch-retrieve` | The champion's `champion_holdout_auc`, `champion_realized_auc`, `champion_lift_at_10`, `champion_is_preliminary`, `champion_realized_auc_trend`, `people_scored`, `likely_count`, `first_check_expected_at` and `coverage`. Start here. |+| `posthog:autoresearch-online-performance-retrieve` | One row per model per validated date: realized AUC with a 95% interval, Brier score, calibration error and bins, mean prediction against base rate, lift at 10% and 20%. |+| `posthog:autoresearch-models-list` | Every champion, challenger and archived model with its scores. Use it to see whether a retrain promoted a new champion. |+| `posthog:autoresearch-models-retrieve` | One model's recipe (feature SQL, transforms, model class) and its feature importances. |+| `posthog:autoresearch-training-runs-history` | Each run's distilled summary: what won, what was tried and dropped. |++## The quality label++The UI gives each champion a label from AUC, and states its basis:++| Label | AUC |+| ------ | ---------- |+| Strong | 0.8 and up |+| Fair | 0.7 to 0.8 |+| Weak | below 0.7 |++- The basis is **confirmed** when the champion has realized AUC and `champion_is_preliminary` is false. Otherwise it is **testing only** and comes from holdout AUC.+- A new champion has no realized rows until its first horizon has passed. `first_check_expected_at` says when the first check is due.+- AUC 0.5 is a coin flip. Above about 0.97 on holdout is suspicious: check that the features do not read the target or something that happens because of it.++## When realized AUC is missing after the horizon++A validated date where every scored person had the same outcome has no AUC.+Its online performance row carries the warning `single_class_no_auc`.+This is common on a rare target with a short horizon.+Tell the user that realized AUC needs dates where some people did the target and some did not, and that more dates will fill it in.++## When holdout and realized disagree++- **Realized a little below holdout** is normal. A gap of a few hundredths is noise, especially on days with few positives. The interval on each row shows how wide the noise is.+- **Realized far below holdout, consistently** suggests the training data does not look like today's population. Common causes: the inference population differs from the training population, behavior shifted, or the features leaked the outcome during training.+- **One bad day** with a wide interval is not a finding. Look at the trend over 7 or more dates before you draw a conclusion.++## Calibration++AUC measures ranking. Calibration measures whether a 30% score means 30% of those people do the target.++- Compare `mean_p_y` with `base_rate` on each realized row. If `mean_p_y` is clearly above, the model over-predicts. If it is clearly below, it under-predicts.+- On a rare target, training can sample down the negatives. Scoring corrects for that: `$autoresearch_p_y` is the corrected probability, and `$autoresearch_p_y_raw` keeps the model's own score. If calibration is still poor, tell the user to rely on the order and the segments, not on the absolute number.+- The Brier score and calibration error are lower-is-better. Compare them across dates of the same model, not across models with different base rates.++## Lift++Lift at 10% is the clearest sentence for a non-technical reader: "people in the top 10% are 3× more likely than average to do X".+Lift at 20% helps when the user plans to act on a larger group.++## Likelihood segments++The Predictions tab splits scored people into **Likely**, **Possible** and **Unlikely**.++- Once a model has enough realized history, the cut points come from lift over the realized base rate, and the cards read like "2× average or higher".+- Before that, a fixed pair of probability cut points is used.+- A saved cohort keeps the cut point it was created with, so its name states the probability range. Recreate a cohort if the segments move a lot.++## Coverage and freshness++Large populations score in rolling batches, so "scored today" and "everyone has a fresh score" are different claims.++- `coverage` on `posthog:autoresearch-retrieve` has `population`, `with_score`, `never_scored` and the score age in days (average, median, 90th percentile, oldest).+- `never_scored` above zero, or a median score age above the cadence, means a rolling population.+- When the user plans to target by score, check coverage first. A cohort built from the property only includes people who were scored.++## A short report++When the user asks "is my model any good?", answer in this order:++1. The question in plain words, and the label with its basis ("Fair, confirmed by real outcomes").+2. Lift at 10% as one sentence.+3. The realized trend: stable, improving or drifting, with the number of dates it rests on.+4. Anything that limits trust: few positives, poor calibration, low coverage, a champion too new to check.+5. One next step: wait for more dates, act on the Likely segment, or steer the next training run.diff --git a/products/autoresearch/skills/working-with-autoresearch/references/troubleshooting-and-steering.md b/products/autoresearch/skills/working-with-autoresearch/references/troubleshooting-and-steering.mdnew file mode 100644index 000000000000..4cb3ec4f703d--- /dev/null+++ b/products/autoresearch/skills/working-with-autoresearch/references/troubleshooting-and-steering.md@@ -0,0 +1,50 @@+# Troubleshooting and steering++## First look++For any "something is wrong with my model" question, read these three, in this order:++1. `posthog:autoresearch-retrieve`: status, champion, last scored time, coverage.+2. `posthog:autoresearch-training-runs-list`: the newest training runs, their status, `iteration_count`, `best_holdout_score` and `error`.+3. `posthog:autoresearch-runs-list`: the newest scoring and validation runs, their status, `rows_scored` and `error`.++## Symptoms++| Symptom | Likely cause | What to do |+| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| Training run shows 0 iterations but is `running` | Normal. Counters are written only when the run completes. | Wait. Check again later. |+| Training run `failed` with 0 iterations | Usually the environment, not the question: access, quota or a sandbox problem. | Read `error`. Confirm the user has PostHog Desktop access. Retry once from the model page. |+| `posthog:autoresearch-train-create` returns 403 from a sandbox | The call came from inside a sandbox, such as a PostHog AI cloud task. | Ask the user to start training from the model's page. Do not retry. |+| `posthog:autoresearch-train-create` returns 403 about Desktop access | The user has no PostHog Desktop access, which cloud training needs. | The model page refuses too. The user needs Desktop access first. |+| `posthog:autoresearch-train-create` returns 400 | A run is already live, the model is paused, its creator or target is no longer valid, or an action target and a key without `action:read`. | Read the message. Wait for the live run, resume in the UI, add the `action:read` scope, or recreate the model only when the target or creator is gone. |+| Training completed but no champion | No experiment produced a usable model, or none beat the current champion. | Read the run's summary with `posthog:autoresearch-training-runs-history`. Check the base rate and positive count. |+| Scores barely vary at all | An identifier mismatch between the features and the people being scored. | Check the spread with the quantile query in [using-predictions.md](using-predictions.md) first: on a rare target, healthy scores can all be small. If the quantiles are the same value, read the champion's feature SQL with `posthog:autoresearch-models-retrieve`. Every row must be keyed on the person id. |+| Holdout AUC above about 0.97 | The features likely see the outcome, or a proxy that happens because of it. | Read the feature importances. If the top feature is the target or a step after it, suggest removing it. |+| Scoring run `failed` | The feature query was too heavy, or a transient error. | Read `error`. After two scheduled days in a row of repeatable failures, the product starts a small rescue training run to find a champion that can score. It can fail too, so check the next training runs rather than waiting. A repeated memory error means the features scan too much: steer the next run toward shorter windows. |+| Fewer people in a cohort than `rows_scored` | Some scored people could not be resolved to a current distinct ID. They get an event but no property. | Expected for a small share. Use the events for analysis that must include everyone. |+| Population only partly scored | Rolling batches on a large population. | Expected. Read `coverage` on `posthog:autoresearch-retrieve`. |+| No realized AUC before the horizon | The horizon has not passed since the champion's first scoring. | Wait. `first_check_expected_at` on `posthog:autoresearch-retrieve` says when. |+| No realized AUC after the horizon | Each validated date had only one outcome class (warning `single_class_no_auc`). | Explain that AUC needs dates with both outcomes. More dates fill it in. On a very rare target, consider a longer horizon. |+| Realized AUC drops over several dates | Behavior shifted, or the training population no longer matches who is scored. | Compare training and inference populations. Retrain, or steer with a suggestion. |++## Steering with suggestions++A suggestion is a note to the training agent. It reads queued suggestions at the start of the next training run.++- `posthog:autoresearch-suggestions-create` with a free-text `prompt`.+ Good suggestions name a hypothesis: "account for day-of-week, the target spikes on Mondays", "try features from the billing page events", "drop the recency feature, I suspect it leaks".+- `priority: "try_next"` makes the agent act on it before its own ideas. The default `consider` is advisory.+- After the next run, `posthog:autoresearch-suggestions-list` shows how the agent handled each one: `acted_on`, `picked_up` or `dismissed`, with a one-line `agent_response`.+- Suggestions do not start a run. Start one from the model page, or with `posthog:autoresearch-train-create` after the user confirms.++The agent decides whether a suggestion helps, and the server still picks the champion by score. A suggestion that makes the model worse is recorded and dropped.++## When to start over++Create a new model instead of retraining when:++- The target, horizon or population should change. These are frozen once a model exists.+- The validation counts were marginal and the realized AUC has stayed near 0.5 for many dates.+- The question no longer matches what the team acts on.++Leave the old model in place until the new one has realized results, then pause or delete the old one in the UI.diff --git a/products/autoresearch/skills/working-with-autoresearch/references/using-predictions.md b/products/autoresearch/skills/working-with-autoresearch/references/using-predictions.mdnew file mode 100644index 000000000000..3272f00a9252--- /dev/null+++ b/products/autoresearch/skills/working-with-autoresearch/references/using-predictions.md@@ -0,0 +1,104 @@+# Using predictions++A scored model writes its output in two places. Pick the one that fits the job.++| Output | Holds | Use it for |+| -------------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------- |+| The output person property | The newest probability for each scored person who resolves to a current distinct ID | Cohorts, feature flag targeting, workflow audiences, breakdowns |+| `autoresearch_prediction` events | One event per scored person per scoring run, with full history | Score history, comparisons across models, custom analysis in SQL |++Take the property name from `output_person_property` on `posthog:autoresearch-retrieve`.+A scored person whose identity cannot be resolved still gets an event, but no property. So a cohort on the property can hold fewer people than the run reports as scored.++## Event properties++| Property | Meaning |+| ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |+| `$autoresearch_p_y` | The probability that the person does the target within the horizon, corrected for any negative sampling in training. |+| `$autoresearch_pipeline_id` | The model (pipeline) id. Always filter on it: a project can have several models. |+| `$autoresearch_model_id` | The champion that produced the score. Changes when a retrain promotes a new one. |+| `$autoresearch_model_role` | `champion`, or `shadow` for a challenger scored alongside it before any promotion. Shadow events set no property. Filter on `champion`. |+| `$autoresearch_prediction_date` | The date the score is for. The horizon starts here. |+| `$autoresearch_target_event` / `$autoresearch_horizon_days` | The question the score answers. |+| `$autoresearch_person_id` | The scored person. Use it as the person key: some prediction events have no person attached. |++## Common queries++Confirm the event exists with `posthog:read-data-schema` first. It appears only after the first scoring run.++Both queries read the newest prediction date only, so a manual score and the daily run do not mix, and a model that scores every few days still returns rows.+On a large population that scores in rolling batches, the newest date holds only that day's batch.++Top people from the newest prediction date:++```sql+WITH latest AS (+ SELECT max(properties.$autoresearch_prediction_date) AS d+ FROM events+ WHERE event = 'autoresearch_prediction'+ AND properties.$autoresearch_pipeline_id = '<pipeline_id>'+ AND properties.$autoresearch_model_role = 'champion'+ AND timestamp > now() - INTERVAL 30 DAY+)+SELECT+ coalesce(nullIf(properties.$autoresearch_person_id, ''), distinct_id) AS person,+ argMax(toFloat(properties.$autoresearch_p_y), timestamp) AS p+FROM events+WHERE event = 'autoresearch_prediction'+ AND properties.$autoresearch_pipeline_id = '<pipeline_id>'+ AND properties.$autoresearch_model_role = 'champion'+ AND timestamp > now() - INTERVAL 30 DAY+ AND properties.$autoresearch_prediction_date = (SELECT d FROM latest)+GROUP BY person+ORDER BY p DESC+LIMIT 50+```++Score spread on the newest prediction date, one score per person:++```sql+WITH latest AS (+ SELECT max(properties.$autoresearch_prediction_date) AS d+ FROM events+ WHERE event = 'autoresearch_prediction'+ AND properties.$autoresearch_pipeline_id = '<pipeline_id>'+ AND properties.$autoresearch_model_role = 'champion'+ AND timestamp > now() - INTERVAL 30 DAY+)+SELECT+ count() AS people,+ min(p) AS min_p,+ quantiles(0.1, 0.5, 0.9, 0.99)(p) AS p10_p50_p90_p99,+ max(p) AS max_p+FROM (+ SELECT+ coalesce(nullIf(properties.$autoresearch_person_id, ''), distinct_id) AS person,+ argMax(toFloat(properties.$autoresearch_p_y), timestamp) AS p+ FROM events+ WHERE event = 'autoresearch_prediction'+ AND properties.$autoresearch_pipeline_id = '<pipeline_id>'+ AND properties.$autoresearch_model_role = 'champion'+ AND timestamp > now() - INTERVAL 30 DAY+ AND properties.$autoresearch_prediction_date = (SELECT d FROM latest)+ GROUP BY person+)+```++On a rare target, healthy scores sit close together near zero, so look at the quantiles rather than equal-width buckets.+Quantiles that are all the same value point to an identifier problem. See [troubleshooting-and-steering.md](troubleshooting-and-steering.md).++## Acting on the scores++- **Cohort.** A dynamic cohort on the output property, for example `<output property> >= 0.6`. It updates as scores change.+- **Feature flag.** Target the flag with the same person property condition to show something only to the Likely group.+- **Workflow.** A batch workflow with the property as its audience filter, for example an email to people at risk of going inactive (low activity score).+- **Insight.** Break down the target event by the output property to show that higher scores really do the target more often.++The model page has shortcuts for these on the Predictions tab. They build the same filters.++Points worth telling the user:++- For `at_risk_of_inactivity`, the at-risk group is a **low** score, because the model predicts activity.+- Pick a threshold from the segments or the score spread, not a round number. On a rare target, 0.6 can match almost nobody.+- People who were never scored have no property value. A filter like `< 0.2` leaves them out, which is usually right, but check coverage on a large population.+- To measure the impact of acting on a score, hold back a random part of the targeted group. The prediction says who is likely; only a holdout shows that the action changed anything.