: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(signals): show ranking lift instead of raw probability (#110636)
posthog[bot]c0cb25e4710d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 2469c9a8a2f8..aa167a2e9b54 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -12987,13 +12987,13 @@ snapshots:scenes-app-signals-artefactloglist--narrow--light:hash: v1.k794b7964.b544f07f6f96dd129bb05ad8f0847e135cb5ddacfb06f71ca7f6dea8567eeb25.l42DAUVqekLSLPYqQtoKHZtTbqH27PeNMG8swIkku3Mscenes-app-signals-artefactloglist--ranking-score--dark:- hash: v1.k794b7964.e91bde1d05b29532e240583be75cadb24b1bd59429801cdbf93ea8cacaff908a.mLrIHfiWoKr4keRohu9nY5e1hQns6qnNpTGt_dEeQTs+ hash: v1.k794b7964.a1cdfe743da3d2a27f7c85348a21b91bbd53ee02d1b9b6343f655cf042429855.EzgFt1k__5XCzw-0kS-sIYCpda-wtXeRCWmr05Q7n8Mscenes-app-signals-artefactloglist--ranking-score--light:- hash: v1.k794b7964.72fd7470f9106cf34eb5933b1f16c57bc3151f34b660a92820930107487dc60c.T_Fa3YaQ64pCB30hqbtLwJBRJfyhm8lKUhwYhICYnw0+ hash: v1.k794b7964.050c82bd6a9b5a30635677b03aed359aefafc825ea2545c5d1c61a4094587103.RWpu_yd7-1cgZXSOaGp2xtgDCH0AKCp1PaTjpItHROkscenes-app-signals-artefactloglist--ranking-score-narrow--dark:- hash: v1.k794b7964.e5fdcf08501bfdcd73e1924247cd2179ee56fece5afd29decccf5afba403de32.bDQ2zxjoyqIfhic370qzv4Y7SwpGfXGO_DH1Eh3mV_g+ hash: v1.k794b7964.c42f2e1343bcdb3af03821ddc41269dfdde5f66c30cd52bb12cfe4133b4b5bb7.4plC8pdl_1Ju8IFWB8eqxCN8cUApwkNJ1MmA6JLoHZkscenes-app-signals-artefactloglist--ranking-score-narrow--light:- hash: v1.k794b7964.a22a2e79b308029f940ef0871f3b302beb10c7c28e76961e893d35b2d9967deb.SXI51Can_bZBO6MQwuLr00TuQHZQFHE2T3Ti53nRaOY+ hash: v1.k794b7964.61a61a657c98db9fb58f9f2b5ce2ca8fa5a61d3618fa87241e57709d7a4653e1.CuCHWqC9HRUTVypQtpAbEwjxOkxmI-WoI1K6t1STd80scenes-app-signals-artefactloglist--replacement-lifecycle--dark:hash: v1.k794b7964.f723b2160bdf85cd5a827fa3dac4c281d75950f47555cdef7fc01f2ef689dfc6.wAOg7AG2Pf4mYO8EjKdD8lFlC1Ulv4MhkXIEMkzfCrgscenes-app-signals-artefactloglist--replacement-lifecycle--light:diff --git a/products/signals/frontend/inbox/components/cards/RankingLiftBar.tsx b/products/signals/frontend/inbox/components/cards/RankingLiftBar.tsxnew file mode 100644index 000000000000..abe6a25c398a--- /dev/null+++ b/products/signals/frontend/inbox/components/cards/RankingLiftBar.tsx@@ -0,0 +1,21 @@+import clsx from 'clsx'++import { rankingLiftBarPercent } from './rankingFormat'++/** A lift on a log scale with a tick at 1x. A head without a lift shows an empty track. */+export function RankingLiftBar({ lift, className }: { lift: number | null; className?: string }): JSX.Element {+ return (+ <span className="relative block h-1.5 overflow-hidden rounded-full">+ {/* The track and tick take the text color, so they keep contrast in a dark tooltip and on a light card. */}+ <span className="absolute inset-0 bg-current opacity-20" aria-hidden />+ {lift !== null ? (+ <span+ className={clsx('relative block h-full rounded-full', className ?? 'bg-current')}+ // oxlint-disable-next-line react/forbid-dom-props+ style={{ width: `${rankingLiftBarPercent(lift)}%` }}+ />+ ) : null}+ <span className="absolute inset-y-0 left-1/2 w-px bg-current opacity-60" aria-hidden />+ </span>+ )+}diff --git a/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx b/products/signals/frontend/inbox/components/cards/ReportCard.test.tsxindex 7529d0a90117..f2dd9eea3dec 100644--- a/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx+++ b/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx@@ -370,9 +370,14 @@ describe('ReportCard', () => {})it.each([- ['with the impact column', true, 'ranking_pr_merged', '41% merge'],- ['without the impact column', false, 'ranking_action', '6.2% action'],- ] as const)('shows the active head probability in the meta row %s', (_name, impactColumn, sortField, tagText) => {+ ['with the impact column', true, 'ranking_pr_merged', '2.7x merge'],+ [+ 'without the impact column, falling back to the probability for a head with no lift',+ false,+ 'ranking_action',+ '6.2% action',+ ],+ ] as const)('shows the active head lift in the meta row %s', (_name, impactColumn, sortField, tagText) => {// The harness renders a card for every test; these assert against their own.cleanup()enableRedesign(impactColumn)@@ -385,7 +390,7 @@ describe('ReportCard', () => {manifest_version: 'manifest',scored_at: '2026-09-30T12:00:00Z',scores: { pr_merged: 0.41, action: 0.062 },- lifts: {},+ lifts: { pr_merged: 2.7 },readable_heads: ['action', 'pr_merged'],},})diff --git a/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx b/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsxindex b252261677a5..1b2fdbb20f44 100644--- a/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx+++ b/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx@@ -5,12 +5,12 @@ import { LemonTag, Tooltip } from '@posthog/lemon-ui'import { RANKING_HEAD_LABELS, RANKING_SORT_HEADS } from '../../filterOptions'import type { InboxRankingSortField } from '../../logics/inboxFiltersLogic'import { SignalReport } from '../../types'+import { formatRankingLift, formatRankingProbability } from './rankingFormat'+import { RankingLiftBar } from './RankingLiftBar'-/** No decimals at 10% and above. Heads such as `action` have low base rates, so one decimal below 10%. */-export function formatRankingProbability(probability: number): string {- const percent = probability * 100- const oneDecimal = Math.round(percent * 10) / 10- return oneDecimal >= 10 ? `${Math.round(percent)}%` : `${oneDecimal.toFixed(1)}%`+function rankingLift(ranking: NonNullable<SignalReport['ranking']>, head: string): number | null {+ const lift = ranking.lifts?.[head]+ return typeof lift === 'number' && Number.isFinite(lift) ? lift : null}function RankingTooltip({@@ -24,33 +24,34 @@ function RankingTooltip({(name) => typeof ranking.scores[name] === 'number')return (- <div className="flex min-w-56 flex-col gap-1 text-xs">+ <div className="flex min-w-72 flex-col gap-1 text-xs">{heads.map((name) => {const probability = ranking.scores[name]+ const lift = rankingLift(ranking, name)return (<div key={name} className={clsx('flex items-center gap-2', name === head && 'font-bold')}><span className="w-28 shrink-0">{RANKING_HEAD_LABELS[name] ?? name}</span>- <span className="h-1.5 flex-1 overflow-hidden rounded-full bg-fill-tertiary">- <span- className="block h-full rounded-full bg-current"- // oxlint-disable-next-line react/forbid-dom-props- style={{ width: `${Math.round(probability * 100)}%` }}- />+ <span className="flex-1">+ <RankingLiftBar lift={lift} /></span><span className="w-10 shrink-0 text-right tabular-nums">+ {lift !== null ? formatRankingLift(lift) : null}+ </span>+ <span className="w-10 shrink-0 text-right font-normal tabular-nums opacity-70">{formatRankingProbability(probability)}</span></div>)})}- <div className="mt-1 border-t border-primary pt-1 font-mono text-muted">+ <div className="opacity-70">Compared with the average report</div>+ <div className="mt-1 border-t border-primary pt-1 font-mono opacity-70">{ranking.model_name}@{ranking.model_version}</div></div>)}-/** The active model sort's probability for one report, in the card's meta row. */+/** The active model sort's lift for one report, in the card's meta row. Falls back to the probability when the head has no lift. */export function ReportCardRankingTag({report,sortField,@@ -60,6 +61,7 @@ export function ReportCardRankingTag({}): JSX.Element {const { head, tagLabel } = RANKING_SORT_HEADS[sortField]const probability = report.ranking?.scores[head]+ const lift = report.ranking ? rankingLift(report.ranking, head) : nullif (!report.ranking || typeof probability !== 'number') {return (<LemonTag size="small" type="muted" data-attr="inbox-ranking-tag">@@ -70,7 +72,7 @@ export function ReportCardRankingTag({return (<Tooltip title={<RankingTooltip ranking={report.ranking} head={head} />}><LemonTag size="small" className="cursor-help tabular-nums" data-attr="inbox-ranking-tag">- {formatRankingProbability(probability)} {tagLabel}+ {lift !== null ? formatRankingLift(lift) : formatRankingProbability(probability)} {tagLabel}</LemonTag></Tooltip>)diff --git a/products/signals/frontend/inbox/components/cards/rankingFormat.test.ts b/products/signals/frontend/inbox/components/cards/rankingFormat.test.tsnew file mode 100644index 000000000000..be7fb27fefa2--- /dev/null+++ b/products/signals/frontend/inbox/components/cards/rankingFormat.test.ts@@ -0,0 +1,29 @@+import { formatRankingLift, rankingLiftBarPercent } from './rankingFormat'++describe('rankingFormat', () => {+ test.each([+ [0.04, '0.0x'],+ [1, '1.0x'],+ [2.74, '2.7x'],+ [9.94, '9.9x'],+ [9.96, '10x'],+ [12.4, '12x'],+ ])('formats a lift of %s as %s', (lift, expected) => {+ expect(formatRankingLift(lift)).toBe(expected)+ })++ test.each([+ [0, 0],+ [0.05, 0],+ [0.1, 0],+ [1, 50],+ [10, 100],+ [40, 100],+ ])('places a lift of %s at %s% of the bar', (lift, expected) => {+ expect(rankingLiftBarPercent(lift)).toBeCloseTo(expected)+ })++ it('places a lift and its inverse at equal distances from 1x', () => {+ expect(rankingLiftBarPercent(4) - 50).toBeCloseTo(50 - rankingLiftBarPercent(0.25))+ })+})diff --git a/products/signals/frontend/inbox/components/cards/rankingFormat.ts b/products/signals/frontend/inbox/components/cards/rankingFormat.tsnew file mode 100644index 000000000000..f1a7da948548--- /dev/null+++ b/products/signals/frontend/inbox/components/cards/rankingFormat.ts@@ -0,0 +1,24 @@+/** No decimals at 10% and above. Heads such as `action` have low base rates, so one decimal below 10%. */+export function formatRankingProbability(probability: number): string {+ const percent = probability * 100+ const oneDecimal = Math.round(percent * 10) / 10+ return oneDecimal >= 10 ? `${Math.round(percent)}%` : `${oneDecimal.toFixed(1)}%`+}++/** One decimal below 10x, no decimals at 10x and above. */+export function formatRankingLift(lift: number): string {+ const oneDecimal = Math.round(lift * 10) / 10+ return oneDecimal >= 10 ? `${Math.round(lift)}x` : `${oneDecimal.toFixed(1)}x`+}++/**+ * Bar width in percent for a lift on a log scale. 1x sits at 50%, and the bar clamps at 0.1x and 10x,+ * so a lift and its inverse sit at equal distances from the center.+ */+export function rankingLiftBarPercent(lift: number): number {+ if (!(lift > 0)) {+ return 0+ }+ const position = (Math.log10(lift) + 1) / 2+ return Math.min(1, Math.max(0, position)) * 100+}diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsxindex 7442ac1e5bb7..7a4abc531982 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx@@ -270,11 +270,12 @@ const rankingArtefacts = [feature_schema_version: 3,status: 'scored',scores: { action: 0.78, pr_merged: 0.52, dismiss_wrong: 0.14, reviewer_fix: 0.04 },+ lifts: { action: 1.3, pr_merged: 2.6, dismiss_wrong: 0.7 },metadata: {heads: [- { head: 'action', readable: true },- { head: 'pr_merged', readable: true },- { head: 'dismiss_wrong', readable: true },+ { head: 'action', readable: true, refit_classification_threshold: 0.6 },+ { head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },+ { head: 'dismiss_wrong', readable: true, refit_classification_threshold: 0.2 },{ head: 'reviewer_fix', readable: false },],},@@ -289,9 +290,9 @@ const rankingArtefacts = [scores: { action: 0.74, pr_merged: 0.55, dismiss_wrong: 0.11 },metadata: {heads: [- { head: 'action', readable: true },- { head: 'pr_merged', readable: true },- { head: 'dismiss_wrong', readable: true },+ { head: 'action', readable: true, refit_classification_threshold: 0.6 },+ { head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },+ { head: 'dismiss_wrong', readable: true, refit_classification_threshold: 0.2 },],},},diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsxindex 69f188aa61ad..dabe7aa4dd0d 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx@@ -189,7 +189,7 @@ describe('ArtefactLogList', () => {)})- it('shows the served ranking model heads, highest first, with challengers behind a disclosure', () => {+ it('shows the served ranking model heads, highest lift first, with challengers behind a disclosure', () => {const { container } = render(<ArtefactLogListreportId="report-1"@@ -203,12 +203,14 @@ describe('ArtefactLogList', () => {'report_embeddings@2026-06-10': {status: 'scored',roles: ['served'],- scores: { pr_merged: 0.52, action: 0.78, refund: 0.04 },+ scores: { pr_merged: 0.52, action: 0.78, refund: 0.04, open: 0.9 },+ lifts: { action: 1.5 },metadata: {heads: [- { head: 'action', readable: true },- { head: 'pr_merged', readable: true },- { head: 'refund', readable: false },+ { head: 'action', readable: true, refit_classification_threshold: 0.6 },+ { head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },+ { head: 'refund', readable: false, refit_classification_threshold: 0.01 },+ { head: 'open', readable: true },],},},@@ -227,8 +229,10 @@ describe('ArtefactLogList', () => {)expect(screen.getByText('Ranking scored')).toBeInTheDocument()- expect(screen.getAllByText(/^\d+%$/).map((node) => node.textContent)).toEqual(['78%', '52%', '4%'])- expect(screen.getByLabelText('No holdout read for this head yet').closest('span')).toHaveTextContent('4%')+ // Stored lifts win over the metadata threshold, and a head with no threshold sorts last.+ expect(screen.getAllByText(/^[\d.]+x$/).map((node) => node.textContent)).toEqual(['4.0x', '2.6x', '1.5x'])+ expect(screen.getAllByText(/^[\d.]+%$/).map((node) => node.textContent)).toEqual(['4.0%', '52%', '78%', '90%'])+ expect(screen.getByLabelText('No holdout read for this head yet').closest('span')).toHaveTextContent('4.0%')expect(screen.getByText('Other models (1)')).toBeInTheDocument()expect(container.querySelector('details')).not.toHaveAttribute('open')expect(screen.getByText('Skipped: missing report vector')).toBeInTheDocument()diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsxindex d51c8e2682ce..f904be0b20ac 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx@@ -40,6 +40,8 @@ import { PRIORITY_TAG_TYPE } from '../../filterOptions'import { SignalCard } from '../../SignalCard'import { EnrichedReviewer, SignalReportActionability, SignalReportPriority, SignalReportArtefact } from '../../types'import { SignalReportActionabilityBadge } from '../badges/SignalReportActionabilityBadge'+import { formatRankingLift, formatRankingProbability } from '../cards/rankingFormat'+import { RankingLiftBar } from '../cards/RankingLiftBar'import { SignalCardDisclosureProvider } from '../signalCards/SignalCardShell'import { ArtefactCommit } from './ArtefactCommit'import { ArtefactPullRequest } from './ArtefactPullRequest'@@ -476,25 +478,21 @@ function CodeReviewBody({ content }: { content: CodeReviewContent }): JSX.Elemenfunction RankingHeadRows({ heads }: { heads: RankingHead[] }): JSX.Element {return (- <div className="grid grid-cols-[minmax(0,max-content)_minmax(2rem,10rem)_auto] items-center justify-start gap-x-2 gap-y-1">+ <div className="grid grid-cols-[minmax(0,max-content)_minmax(2rem,10rem)_auto_auto] items-center justify-start gap-x-2 gap-y-1">{heads.map((head) => {- const percent = Math.round(head.probability * 100)+ const tone = head.readable ? 'text-default' : 'text-tertiary'return (<Fragment key={head.name}>- <span className={`truncate ${head.readable ? 'text-default' : 'text-tertiary'}`}>- {prettify(head.name)}+ <span className={`truncate ${tone}`}>{prettify(head.name)}</span>+ <RankingLiftBar+ lift={head.lift}+ className={head.readable ? 'bg-primary-3000' : 'bg-border-bold'}+ />+ <span className={`text-right tabular-nums ${tone}`}>+ {head.lift !== null ? formatRankingLift(head.lift) : null}</span>- <div className="h-1.5 overflow-hidden rounded-full bg-border-light">- <div- className={`h-full rounded-full ${head.readable ? 'bg-primary-3000' : 'bg-border-bold'}`}- // eslint-disable-next-line react/forbid-dom-props- style={{ width: `${percent}%` }}- />- </div>- <span- className={`inline-flex items-center justify-end gap-1 tabular-nums ${head.readable ? 'text-default' : 'text-tertiary'}`}- >- {percent}%+ <span className="inline-flex items-center justify-end gap-1 tabular-nums text-tertiary">+ {formatRankingProbability(head.probability)}{head.readable ? (<span className="size-3" aria-hidden />) : (diff --git a/products/signals/frontend/inbox/components/detail/artefactTypes.ts b/products/signals/frontend/inbox/components/detail/artefactTypes.tsindex d934a45dcfb4..fa6125abcab6 100644--- a/products/signals/frontend/inbox/components/detail/artefactTypes.ts+++ b/products/signals/frontend/inbox/components/detail/artefactTypes.ts@@ -189,10 +189,14 @@ export const WORK_RELEASE_REASON_LABELS: Record<NonNullable<WorkReleaseContent['// ── Ranking scores (staff only) ──────────────────────────────────────────────────────────────-/** One outcome head of a ranking model. `readable` is false when the head has no holdout AUC yet. */+/**+ * One outcome head of a ranking model. `readable` is false when the head has no holdout AUC yet.+ * `lift` is the probability over the head's base rate, or null when the model saved no base rate.+ */export interface RankingHead {name: stringprobability: number+ lift: number | nullreadable: boolean}@@ -201,7 +205,7 @@ export interface RankingModel {roles: string[]status: 'scored' | 'skipped'skipReason: string | null- /** Highest probability first. */+ /** Highest lift first. Heads without a lift come last, highest probability first. */heads: RankingHead[]}@@ -220,15 +224,53 @@ function readableHeadNames(metadata: unknown): Set<string> {)}+/** Mirrors `classification_thresholds` in `ranking/model_contract.py`. */+function classificationThresholds(metadata: unknown): Map<string, number> {+ const heads = isObject(metadata) && Array.isArray(metadata.heads) ? metadata.heads : []+ const thresholds = new Map<string, number>()+ for (const entry of heads) {+ if (isObject(entry) && typeof entry.refit_classification_threshold === 'number') {+ thresholds.set(String(entry.head), entry.refit_classification_threshold)+ }+ }+ return thresholds+}++/** Reads the stored lift first. Otherwise mirrors `head_lifts` in `ranking/model_contract.py`. */+function headLift(name: string, probability: number, lifts: unknown, thresholds: Map<string, number>): number | null {+ const stored = isObject(lifts) ? lifts[name] : undefined+ if (typeof stored === 'number' && Number.isFinite(stored)) {+ return stored+ }+ const threshold = thresholds.get(name) ?? 0+ return threshold > 0 ? probability / threshold : null+}++function compareRankingHeads(a: RankingHead, b: RankingHead): number {+ if (a.lift !== null && b.lift !== null) {+ return b.lift - a.lift+ }+ if (a.lift !== null || b.lift !== null) {+ return a.lift === null ? 1 : -1+ }+ return b.probability - a.probability+}+function readRankingModel(key: string, value: unknown): RankingModel | null {if (!isObject(value) || (value.status !== 'scored' && value.status !== 'skipped')) {return null}const readable = readableHeadNames(value.metadata)+ const thresholds = classificationThresholds(value.metadata)const heads = Object.entries(isObject(value.scores) ? value.scores : {}).filter((entry): entry is [string, number] => typeof entry[1] === 'number' && Number.isFinite(entry[1]))- .map(([name, probability]) => ({ name, probability, readable: readable.has(name) }))- .sort((a, b) => b.probability - a.probability)+ .map(([name, probability]) => ({+ name,+ probability,+ lift: headLift(name, probability, value.lifts, thresholds),+ readable: readable.has(name),+ }))+ .sort(compareRankingHeads)return {key,roles: Array.isArray(value.roles) ? value.roles.filter((role): role is string => typeof role === 'string') : [],