Skip to content

: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.

feat(autoresearch): show model quality in plain language on the model list (#113122)

posthog[bot]8c14286e6358
diff --git a/products/autoresearch/backend/facade/api.py b/products/autoresearch/backend/facade/api.py
index fc580dd435c5..4457295c4305 100644
--- a/products/autoresearch/backend/facade/api.py
+++ b/products/autoresearch/backend/facade/api.py
@@ -127,11 +127,25 @@ def _as_uuid(value: str | UUID | None) -> UUID | None:
# ── Mappers ────────────────────────────────────────────────────────────────
+def _champion_lift_at_10(champion: AutoresearchModel | None) -> float | None:
+ """Lift in the top decile on the champion's latest validated prediction date.
+
+ None when no scored person did the target on that date. Lift has no value without positives,
+ and online validation stores 0.0 for it only as a fallback.
+ """
+ if champion is None:
+ return None
+ realized = (champion.metrics or {}).get("realized") or {}
+ if realized.get("n_positive") == 0:
+ return None
+ lift = realized.get("lift_at_10")
+ return float(lift) if isinstance(lift, int | float) else None
+
+
def _pipeline_to_contract(
row: AutoresearchPipeline,
*,
- champion_holdout_auc: float | None = None,
- champion_realized_auc: float | None = None,
+ champion: AutoresearchModel | None = None,
) -> Pipeline:
return Pipeline(
id=row.id,
@@ -158,18 +172,16 @@ def _pipeline_to_contract(
created_at=row.created_at,
updated_at=row.updated_at,
last_scored_at=row.last_scored_at,
- champion_holdout_auc=champion_holdout_auc,
- champion_realized_auc=champion_realized_auc,
+ champion_holdout_auc=champion.holdout_score if champion else None,
+ champion_realized_auc=champion.realized_score if champion else None,
+ champion_lift_at_10=_champion_lift_at_10(champion),
+ champion_is_preliminary=champion.is_preliminary if champion else None,
)
def _pipeline_with_champion(row: AutoresearchPipeline) -> Pipeline:
champion = row.models.filter(role=AutoresearchModel.Role.CHAMPION).order_by("-created_at").first()
- return _pipeline_to_contract(
- row,
- champion_holdout_auc=champion.holdout_score if champion else None,
- champion_realized_auc=champion.realized_score if champion else None,
- )
+ return _pipeline_to_contract(row, champion=champion)
def _model_to_contract(row: AutoresearchModel, *, in_shadow_set: bool) -> Model:
@@ -343,7 +355,20 @@ def list_pipelines(team_id: int, *, offset: int, limit: int) -> tuple[list[Pipel
.order_by("-created_at")
)
count = qs.count()
- return [_pipeline_with_champion(row) for row in qs[offset : offset + limit]], count
+ rows = qs[offset : offset + limit].prefetch_related(
+ Prefetch(
+ "models",
+ queryset=AutoresearchModel.objects.for_team(team_id)
+ .filter(role=AutoresearchModel.Role.CHAMPION)
+ .order_by("-created_at"),
+ to_attr="prefetched_champions",
+ )
+ )
+ pipelines = []
+ for row in rows:
+ champions: list[AutoresearchModel] = row.prefetched_champions
+ pipelines.append(_pipeline_to_contract(row, champion=champions[0] if champions else None))
+ return pipelines, count
def get_pipeline(team_id: int, pipeline_id: str | UUID) -> Pipeline:
diff --git a/products/autoresearch/backend/facade/contracts.py b/products/autoresearch/backend/facade/contracts.py
index 509634a1ba7d..8df14aba5bd8 100644
--- a/products/autoresearch/backend/facade/contracts.py
+++ b/products/autoresearch/backend/facade/contracts.py
@@ -102,6 +102,8 @@ class Pipeline:
last_scored_at: datetime | None
champion_holdout_auc: float | None
champion_realized_auc: float | None
+ champion_lift_at_10: float | None
+ champion_is_preliminary: bool | None
@dataclass(frozen=True)
diff --git a/products/autoresearch/backend/presentation/views/serializers.py b/products/autoresearch/backend/presentation/views/serializers.py
index a63b2f7555d0..2cf4fb753052 100644
--- a/products/autoresearch/backend/presentation/views/serializers.py
+++ b/products/autoresearch/backend/presentation/views/serializers.py
@@ -569,6 +569,16 @@ class AutoresearchPipelineSerializer(DataclassSerializer):
allow_null=True,
help_text="Realized online AUC of the current champion model, computed from mature predictions against actual outcomes.",
)
+ champion_lift_at_10 = serializers.FloatField(
+ read_only=True,
+ allow_null=True,
+ help_text="Lift in the top 10% of scores for the current champion model, from its latest validated prediction date. 2.0 means the top 10% converts at twice the average rate.",
+ )
+ champion_is_preliminary = serializers.BooleanField(
+ read_only=True,
+ allow_null=True,
+ help_text="True while the current champion model has no realized AUC yet. Null when the pipeline has no champion.",
+ )
class Meta:
dataclass = Pipeline
@@ -595,6 +605,8 @@ class AutoresearchPipelineSerializer(DataclassSerializer):
"last_scored_at",
"champion_holdout_auc",
"champion_realized_auc",
+ "champion_lift_at_10",
+ "champion_is_preliminary",
]
diff --git a/products/autoresearch/backend/tests/test_api.py b/products/autoresearch/backend/tests/test_api.py
index 820ec1e053c2..5d9a19234a13 100644
--- a/products/autoresearch/backend/tests/test_api.py
+++ b/products/autoresearch/backend/tests/test_api.py
@@ -173,6 +173,69 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):
assert resp.status_code == status.HTTP_200_OK
assert resp.json()["count"] == 2
+ def test_list_reads_champions_in_one_query(self):
+ validated = self._make_pipeline(name="Validated")
+ AutoresearchModel.objects.create(
+ pipeline=validated,
+ role=AutoresearchModel.Role.ARCHIVED,
+ model_recipe={"stub": True},
+ recipe_hash="old",
+ metrics={"realized": {"lift_at_10": 9.0, "prediction_date": "2026-01-01"}},
+ )
+ AutoresearchModel.objects.create(
+ pipeline=validated,
+ role=AutoresearchModel.Role.CHAMPION,
+ model_recipe={"stub": True},
+ recipe_hash="validated",
+ holdout_score=0.81,
+ realized_score=0.78,
+ is_preliminary=False,
+ metrics={"realized": {"lift_at_10": 2.4, "prediction_date": "2026-01-02"}},
+ )
+ preliminary = self._make_pipeline(name="Preliminary")
+ AutoresearchModel.objects.create(
+ pipeline=preliminary,
+ role=AutoresearchModel.Role.CHAMPION,
+ model_recipe={"stub": True},
+ recipe_hash="preliminary",
+ holdout_score=0.72,
+ is_preliminary=True,
+ )
+ for name, n_positive in (("No positives", 0), ("Zero lift", 3)):
+ AutoresearchModel.objects.create(
+ pipeline=self._make_pipeline(name=name),
+ role=AutoresearchModel.Role.CHAMPION,
+ model_recipe={"stub": True},
+ recipe_hash=name,
+ holdout_score=0.81,
+ realized_score=0.78,
+ is_preliminary=False,
+ metrics={"realized": {"n_positive": n_positive, "lift_at_10": 0.0, "prediction_date": "2026-01-02"}},
+ )
+ self._make_pipeline(name="Untrained")
+
+ with CaptureQueriesContext(connection) as queries:
+ resp = self.client.get(f"{self.base_url}/")
+
+ assert resp.status_code == status.HTTP_200_OK
+ assert sum("autoresearchmodel" in q["sql"].lower() for q in queries.captured_queries) == 1
+ by_name = {row["name"]: row for row in resp.json()["results"]}
+ assert {
+ name: (
+ row["champion_holdout_auc"],
+ row["champion_realized_auc"],
+ row["champion_lift_at_10"],
+ row["champion_is_preliminary"],
+ )
+ for name, row in by_name.items()
+ } == {
+ "Validated": (0.81, 0.78, 2.4, False),
+ "Preliminary": (0.72, None, None, True),
+ "No positives": (0.81, 0.78, None, False),
+ "Zero lift": (0.81, 0.78, 0.0, False),
+ "Untrained": (None, None, None, None),
+ }
+
def test_archived_pipelines_excluded_from_list(self):
self._make_pipeline(name="Active")
self._make_pipeline(name="Archived", status=AutoresearchPipeline.Status.ARCHIVED)
diff --git a/products/autoresearch/frontend/AutoresearchScene.tsx b/products/autoresearch/frontend/AutoresearchScene.tsx
index fdc89bbca465..033a1da3b79b 100644
--- a/products/autoresearch/frontend/AutoresearchScene.tsx
+++ b/products/autoresearch/frontend/AutoresearchScene.tsx
@@ -20,6 +20,8 @@ import { ProductKey } from '~/queries/schema/schema-general'
import { autoresearchLogic } from './autoresearchLogic'
import { autoresearchEmptyState } from './emptyState/autoresearchEmptyState'
import { AutoresearchPipelineApi } from './generated/api.schemas'
+import { MODEL_QUALITY_THRESHOLDS, modelQuality } from './modelQuality'
+import { ModelQualityTag } from './ModelQualityTag'
import { PipelineStatusTag } from './PipelineStatusTag'
export const scene: SceneExport = {
@@ -69,19 +71,33 @@ export function AutoresearchScene(): JSX.Element {
keyof AutoresearchPipelineApi | undefined
>,
{
- title: 'Holdout AUC',
- dataIndex: 'champion_holdout_auc',
- tooltip: 'Offline AUC of the current champion model, measured on held-out training data.',
- render: (_, record: AutoresearchPipelineApi) =>
- record.champion_holdout_auc == null ? '—' : record.champion_holdout_auc.toFixed(3),
- },
- {
- title: 'Realized AUC',
- dataIndex: 'champion_realized_auc',
- tooltip:
- 'Realized AUC of the current champion model, measured against actual outcomes once predictions matured.',
- render: (_, record: AutoresearchPipelineApi) =>
- record.champion_realized_auc == null ? '—' : record.champion_realized_auc.toFixed(3),
+ title: 'Quality',
+ tooltip: `How well the current champion model ranks people. Strong is an AUC of ${MODEL_QUALITY_THRESHOLDS.strong.toFixed(2)} or more, Fair is ${MODEL_QUALITY_THRESHOLDS.fair.toFixed(2)} to ${MODEL_QUALITY_THRESHOLDS.strong.toFixed(2)}, and Weak is below ${MODEL_QUALITY_THRESHOLDS.fair.toFixed(2)}. Realized AUC from real outcomes is used when it exists, otherwise holdout AUC from test data.`,
+ render: (_, record: AutoresearchPipelineApi) => {
+ const quality = modelQuality({
+ holdoutAuc: record.champion_holdout_auc,
+ realizedAuc: record.champion_realized_auc,
+ liftAt10: record.champion_lift_at_10,
+ isPreliminary: record.champion_is_preliminary,
+ target: record.target_event,
+ })
+ if (!quality) {
+ return <span className="text-secondary">—</span>
+ }
+ return (
+ <div className="flex flex-col gap-0.5">
+ <div className="flex items-center gap-1">
+ <ModelQualityTag
+ quality={quality}
+ holdoutAuc={record.champion_holdout_auc}
+ realizedAuc={record.champion_realized_auc}
+ />
+ <span className="text-xs text-secondary">{quality.basis}</span>
+ </div>
+ <span className="text-xs text-secondary">{quality.sentence}</span>
+ </div>
+ )
+ },
},
{
title: 'Last scored',
diff --git a/products/autoresearch/frontend/ModelQualityTag.tsx b/products/autoresearch/frontend/ModelQualityTag.tsx
new file mode 100644
index 000000000000..b2f3b15a15c5
--- /dev/null
+++ b/products/autoresearch/frontend/ModelQualityTag.tsx
@@ -0,0 +1,46 @@
+import { LemonTag, LemonTagType, Tooltip } from '@posthog/lemon-ui'
+
+import { ModelQuality, ModelQualityVerdict } from './modelQuality'
+
+const VERDICT_TAG_TYPE: Record<ModelQualityVerdict, LemonTagType> = {
+ Strong: 'success',
+ Fair: 'warning',
+ Weak: 'danger',
+}
+
+function formatAuc(auc: number | null | undefined): string {
+ return auc == null ? 'not measured' : auc.toFixed(3)
+}
+
+export function ModelQualityTag({
+ quality,
+ holdoutAuc,
+ realizedAuc,
+}: {
+ quality: ModelQuality
+ holdoutAuc: number | null | undefined
+ realizedAuc: number | null | undefined
+}): JSX.Element {
+ return (
+ <Tooltip
+ title={
+ <div className="flex flex-col gap-1">
+ <div>
+ {quality.basis === 'confirmed'
+ ? `Realized AUC ${quality.auc.toFixed(3)}, measured on real outcomes of past predictions.`
+ : `Holdout AUC ${quality.auc.toFixed(3)}, measured on test data only. Real outcomes are not checked yet.`}
+ </div>
+ <div>
+ AUC shows how well the model ranks people who do the target above people who don't. 0.5 is
+ random and 1.0 is perfect.
+ </div>
+ <div className="text-xs">
+ Holdout AUC: {formatAuc(holdoutAuc)}. Realized AUC: {formatAuc(realizedAuc)}.
+ </div>
+ </div>
+ }
+ >
+ <LemonTag type={VERDICT_TAG_TYPE[quality.verdict]}>{quality.verdict}</LemonTag>
+ </Tooltip>
+ )
+}
diff --git a/products/autoresearch/frontend/generated/api.schemas.ts b/products/autoresearch/frontend/generated/api.schemas.ts
index db2f383c44cf..890906a52d25 100644
--- a/products/autoresearch/frontend/generated/api.schemas.ts
+++ b/products/autoresearch/frontend/generated/api.schemas.ts
@@ -200,6 +200,16 @@ export interface AutoresearchPipelineApi {
* @nullable
*/
readonly champion_realized_auc: number | null
+ /**
+ * Lift in the top 10% of scores for the current champion model, from its latest validated prediction date. 2.0 means the top 10% converts at twice the average rate.
+ * @nullable
+ */
+ readonly champion_lift_at_10: number | null
+ /**
+ * True while the current champion model has no realized AUC yet. Null when the pipeline has no champion.
+ * @nullable
+ */
+ readonly champion_is_preliminary: boolean | null
}
export interface PaginatedAutoresearchPipelineListApi {
diff --git a/products/autoresearch/frontend/modelQuality.test.ts b/products/autoresearch/frontend/modelQuality.test.ts
new file mode 100644
index 000000000000..41dcf1a6726f
--- /dev/null
+++ b/products/autoresearch/frontend/modelQuality.test.ts
@@ -0,0 +1,81 @@
+import { modelQuality } from './modelQuality'
+
+describe('modelQuality', () => {
+ const base = { holdoutAuc: null, realizedAuc: null, liftAt10: null, isPreliminary: false, target: 'signed_up' }
+
+ test.each([
+ {
+ name: 'realized AUC wins over holdout AUC',
+ input: { holdoutAuc: 0.9, realizedAuc: 0.65, liftAt10: 1.24 },
+ expected: {
+ verdict: 'Weak',
+ basis: 'confirmed',
+ auc: 0.65,
+ sentence: 'Top 10% are 1.2× more likely to do signed_up',
+ },
+ },
+ {
+ name: '0.80 is strong',
+ input: { realizedAuc: 0.8, liftAt10: 3.4 },
+ expected: {
+ verdict: 'Strong',
+ basis: 'confirmed',
+ auc: 0.8,
+ sentence: 'Top 10% are 3.4× more likely to do signed_up',
+ },
+ },
+ {
+ name: 'just under 0.80 is fair',
+ input: { holdoutAuc: 0.7999 },
+ expected: {
+ verdict: 'Fair',
+ basis: 'testing only',
+ auc: 0.7999,
+ sentence: 'Not checked against real outcomes yet',
+ },
+ },
+ {
+ name: '0.70 is fair',
+ input: { holdoutAuc: 0.7 },
+ expected: {
+ verdict: 'Fair',
+ basis: 'testing only',
+ auc: 0.7,
+ sentence: 'Not checked against real outcomes yet',
+ },
+ },
+ {
+ name: 'just under 0.70 is weak',
+ input: { holdoutAuc: 0.6999 },
+ expected: {
+ verdict: 'Weak',
+ basis: 'testing only',
+ auc: 0.6999,
+ sentence: 'Not checked against real outcomes yet',
+ },
+ },
+ {
+ name: 'a preliminary champion uses holdout AUC',
+ input: { holdoutAuc: 0.82, realizedAuc: 0.6, isPreliminary: true },
+ expected: {
+ verdict: 'Strong',
+ basis: 'testing only',
+ auc: 0.82,
+ sentence: 'Not checked against real outcomes yet',
+ },
+ },
+ {
+ name: 'a confirmed model with no lift had no one do the target',
+ input: { realizedAuc: 0.78 },
+ expected: {
+ verdict: 'Fair',
+ basis: 'confirmed',
+ auc: 0.78,
+ sentence: 'No one did signed_up in the latest check',
+ },
+ },
+ { name: 'no AUC gives no verdict', input: {}, expected: null },
+ ])('$name', ({ input, expected }) => {
+ expect(modelQuality({ ...base, ...input })).toEqual(expected)
+ })
+})
diff --git a/products/autoresearch/frontend/modelQuality.ts b/products/autoresearch/frontend/modelQuality.ts
new file mode 100644
index 000000000000..58d4953c874e
--- /dev/null
+++ b/products/autoresearch/frontend/modelQuality.ts
@@ -0,0 +1,67 @@
+/**
+ * AUC cutoffs for the quality verdict: Strong at or above `strong`, Fair at or above `fair`, Weak below.
+ * They do not vary by base rate yet. Tune them here after dogfooding.
+ */
+export const MODEL_QUALITY_THRESHOLDS = {
+ strong: 0.8,
+ fair: 0.7,
+} as const
+
+export type ModelQualityVerdict = 'Strong' | 'Fair' | 'Weak'
+
+/** `confirmed` when the verdict comes from realized AUC, `testing only` when it comes from holdout AUC. */
+export type ModelQualityBasis = 'confirmed' | 'testing only'
+
+export interface ModelQuality {
+ verdict: ModelQualityVerdict
+ basis: ModelQualityBasis
+ auc: number
+ sentence: string
+}
+
+export interface ModelQualityInput {
+ holdoutAuc: number | null | undefined
+ realizedAuc: number | null | undefined
+ liftAt10: number | null | undefined
+ isPreliminary: boolean | null | undefined
+ target: string
+}
+
+function modelQualityVerdict(auc: number): ModelQualityVerdict {
+ if (auc >= MODEL_QUALITY_THRESHOLDS.strong) {
+ return 'Strong'
+ }
+ if (auc >= MODEL_QUALITY_THRESHOLDS.fair) {
+ return 'Fair'
+ }
+ return 'Weak'
+}
+
+function liftSentence(liftAt10: number | null | undefined, target: string, confirmed: boolean): string {
+ if (liftAt10 == null) {
+ // A confirmed model has realized metrics, so the API leaves lift null only when no one did the target that day.
+ return confirmed ? `No one did ${target} in the latest check` : 'Not checked against real outcomes yet'
+ }
+ return `Top 10% are ${liftAt10.toFixed(1)}× more likely to do ${target}`
+}
+
+/** Realized AUC measures real outcomes, so it wins over holdout AUC. Null when the model has no AUC at all. */
+export function modelQuality({
+ holdoutAuc,
+ realizedAuc,
+ liftAt10,
+ isPreliminary,
+ target,
+}: ModelQualityInput): ModelQuality | null {
+ const confirmed = realizedAuc != null && !isPreliminary
+ const auc = confirmed ? realizedAuc : holdoutAuc
+ if (auc == null) {
+ return null
+ }
+ return {
+ verdict: modelQualityVerdict(auc),
+ basis: confirmed ? 'confirmed' : 'testing only',
+ auc,
+ sentence: liftSentence(liftAt10, target, confirmed),
+ }
+}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 022528769b1b..17fdc56b2709 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -13682,6 +13682,16 @@ export namespace Schemas {
* @nullable
*/
readonly champion_realized_auc: number | null;
+ /**
+ * Lift in the top 10% of scores for the current champion model, from its latest validated prediction date. 2.0 means the top 10% converts at twice the average rate.
+ * @nullable
+ */
+ readonly champion_lift_at_10: number | null;
+ /**
+ * True while the current champion model has no realized AUC yet. Null when the pipeline has no champion.
+ * @nullable
+ */
+ readonly champion_is_preliminary: boolean | null;
}
/**