Skip to content

fix(experimentation): Results banner declares a winner at any probability, docs say 95% / 5% - #9134

Open
NadyKor15 wants to merge 3 commits into
Flagsmith:mainfrom
NadyKor15:fix/experiments-banner-threshold
Open

NadyKor15 wants to merge 3 commits into
Flagsmith:mainfrom
NadyKor15:fix/experiments-banner-threshold

Conversation

@NadyKor15

@NadyKor15 NadyKor15 commented Nov 26, 2026 •

Copy link
Copy Markdown

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature. (Not needed: the docs already describe this rule.)
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #9133

The results page names a winner and suggests a rollout at any probability. The docs only call a result above 95% (winning) or below 5% (losing): "Over 95% → winning; under 5% → losing; in between → inconclusive." (Statistics), and "When a variation reaches a 95% chance of beating control, a recommendation banner suggests rolling it out." (Analyse an experiment). This PR applies that rule wherever the page names a winner. The statistics and the backend are unchanged.

  • The green "Winner Probability Confirmed" banner and its rollout suggestion appear only when a variant's chance to beat control is over 95%.
  • "Control is the winner" appears only when every variant is under 5%. This is checked against each variant's own chance, so it also works with many variants, where the 1 - Σ bound for control can be small.
  • In between, an info banner says there is no winner yet, gives the leading variant's chance of beating control and its lift, and says what to do next: keep running, or resume a paused experiment. A completed experiment gets "No clear winner" and no next step.
  • The summary card reads "Leading variation" until there is a winner, and the results table only highlights a row in green once it has won.
  • The complete-experiment dialog pre-selects a variant only once it has won. Until then control stays selected, with the existing "No variant has a clear lead yet, so control is selected." message.
  • The banners describe a variant's number as its "chance of beating Control", which is what chance_to_win is. With several variants the control figure is the 1 - Σ lower bound, so the card and the table now show it as "≥ N%". Chances that round to 95% or 5% but sit on the deciding side show as "> 95%" or "< 5%".

The thresholds are two constants in derive.ts, and the new no-winner state uses the DS Banner. Exactly 95% and exactly 5% count as inconclusive, following "over 95%" and "under 5%" on the statistics page. The analyse page says "reaches a 95% chance", so if you would rather include the boundaries, it means switching > and < to >= and <=.

I left the "Chance to be best" card label as it is, although for a variant it shows the chance of beating control. Happy to rename it here or in a follow-up.

Review effort: 2/5

How did you test this code?

Unit tests: npx jest web/components/experiments passes 191 tests in 9 suites (145 on main before this change).

  • results/__tests__/derive.test.ts: getConclusiveWinner at 98%, just over 95%, exactly 95%, 64%, two variants tied at 60% and at 97%, control ahead at 62%, variants either side of 5%, exactly 5%, every variant under or just under 5%, one variant, missing inference, and 20 variants at 4.9% (control wins) or 5% (no winner). deriveSummary covers isConclusive, the "Chance to be best" text and its highlight, including one, two, three, 20 and 21 variants. formatChancePct and formatControlChancePct cover the 95%/5% hedges and the lower bound. getNoWinnerCopy covers running, paused and completed.
  • CompleteExperimentModal/__tests__/utils.test.ts: the old "leading treatment" case at 0.7 now expects control to be pre-selected, and the old "control leads" case (both variants at 5%) now uses 3% and 2%, since exactly 5% is inconclusive. New cases cover 98%, exactly 95%, every variant under 5%, a variant at exactly 5%, and 20 variants under 5%.

npx eslint on the changed files reports no errors. npm run typecheck reports the same errors per file as on main, none of them in the experiments folder.

Screenshots come from a local Storybook story (not part of this PR) that renders ExperimentRecommendation and ExperimentSummaryScorecard with mocked results for one variant. The probabilities match the three cases in #9133, which also has screenshots of the current behaviour on Flagsmith Cloud.

  1. Variant_1 at 64%: was "64% Winner Probability Confirmed", now "Not enough evidence yet".

Variant at 64%: not enough evidence yet

  1. Variant_1 at 38%, control at 62%: was "Control is the winner", now "Not enough evidence yet".

Control at 62%: not enough evidence yet

  1. Variant_1 at 98%: green banner, as before.

Variant at 98%: winner banner

  1. Variant_1 at 3%, control at 97%: "Control is the winner", as before.

Control at 97%: control is the winner

  1. Variant_1 at 64% on a paused experiment: the next step says to resume it.

Paused experiment at 64%

  1. Variant_1 at 64% on a completed experiment: "No clear winner", no next step.

Completed experiment at 64%: no clear winner

…lity, docs say 95% / 5%

Call a winner only when a variant's chance to beat control is over 95%,
or control when every variant is under 5%, as the experimentation docs
describe. In between, the results page shows a neutral "Not enough
evidence yet" banner, the scorecard shows "No winner yet", and the
complete-experiment dialog keeps control pre-selected.

Closes Flagsmith#9133
@NadyKor15
NadyKor15 requested a review from a team as a code owner November 26, 2026 19:26
@NadyKor15
NadyKor15 requested review from talissoncosta and removed request for a team November 26, 2026 19:26
@vercel

vercel Bot commented Nov 26, 2026

Copy link
Copy Markdown

@NadyKor15 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Nov 26, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Confidence score: 4/5

  • In ExperimentRecommendation.tsx, an exact 95% result is inconclusive, but the copy says the probability is below 95%. Say it has not exceeded the 95% threshold so the boundary case is accurate.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/web/components/experiments/results/ExperimentRecommendation.tsx">

<violation number="1" location="frontend/web/components/experiments/results/ExperimentRecommendation.tsx:55">
P2: An exact 95% result is inconclusive, but this copy says its probability is below 95%. Say it has not exceeded the 95% threshold so the boundary case is described accurately.</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

Re-trigger cubic

Comment on lines +55 to +56
below the {formatChancePct(WINNING_CHANCE_THRESHOLD)} needed to
call a winner.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: An exact 95% result is inconclusive, but this copy says its probability is below 95%. Say it has not exceeded the 95% threshold so the boundary case is described accurately.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At frontend/web/components/experiments/results/ExperimentRecommendation.tsx, line 55:

<comment>An exact 95% result is inconclusive, but this copy says its probability is below 95%. Say it has not exceeded the 95% threshold so the boundary case is described accurately.</comment>

<file context>
@@ -21,6 +27,45 @@ const ExperimentRecommendation: FC<ExperimentRecommendationProps> = ({
+              leads with a lift of {summary.liftValue} over{' '}
+              <VariantName name='Control' colour={summary.controlColour} /> and{' '}
+              {summary.chanceToBest} probability of being the best variant,
+              below the {formatChancePct(WINNING_CHANCE_THRESHOLD)} needed to
+              call a winner.
+            </>
</file context>
Suggested change
below the {formatChancePct(WINNING_CHANCE_THRESHOLD)} needed to
call a winner.
which has not exceeded the {formatChancePct(WINNING_CHANCE_THRESHOLD)}
threshold needed to call a winner.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 164df6b. The no-winner banner now reads "Variant_1 has a 64% chance of beating Control, with a lift of +20.3%. A winner needs a chance over 95%.", which stays true at exactly 95%. A chance that rounds to 95% but is above it now shows as "> 95%", so a declared winner never reads as a plain "95%".

…e chances as beating control

Control now wins when every variant is under 5%, checked against each
variant's own chance, so it also holds with many variants. The banner,
summary cards, results table and complete-experiment dialog all use the
same conclusive winner.

The banners describe a variant's number as its chance of beating control.
With several variants the control figure is a lower bound and shows as
"≥ N%". Chances that round to 95% or 5% but sit on the deciding side show
as "> 95%" or "< 5%". Without a winner the summary card reads "Leading
variation", and the banner wording follows the experiment status.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files (changes from recent commits).

Confidence score: 4/5

  • In frontend/web/components/experiments/results/derive.ts, green styling no longer follows the existing >90% probability cutoff: a 92% inconclusive lead can lose green, while a conclusive control with a displayed lower bound of at least 2% can gain it. Keep the established cutoff if this styling change wasn’t intentional.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/web/components/experiments/results/derive.ts">

<violation number="1" location="frontend/web/components/experiments/results/derive.ts:386">
P2: This ties green styling to whether a winner is conclusive instead of the existing >90% probability cutoff: a 92% inconclusive lead loses green, while a conclusive control with a displayed lower bound of ≥2% turns green. Keep this flag based on `winner.chanceToWin > 0.9` to preserve the existing probability-based styling.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

chanceToBest: winner.isControl
? formatControlChancePct(winner.chanceToWin, identities.length - 1)
: formatChancePct(winner.chanceToWin),
chanceToBestHigh: !!conclusiveWinner,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This ties green styling to whether a winner is conclusive instead of the existing >90% probability cutoff: a 92% inconclusive lead loses green, while a conclusive control with a displayed lower bound of ≥2% turns green. Keep this flag based on winner.chanceToWin > 0.9 to preserve the existing probability-based styling.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At frontend/web/components/experiments/results/derive.ts, line 386:

<comment>This ties green styling to whether a winner is conclusive instead of the existing >90% probability cutoff: a 92% inconclusive lead loses green, while a conclusive control with a displayed lower bound of ≥2% turns green. Keep this flag based on `winner.chanceToWin > 0.9` to preserve the existing probability-based styling.</comment>

<file context>
@@ -340,8 +380,10 @@ export const deriveSummary = (
+    chanceToBest: winner.isControl
+      ? formatControlChancePct(winner.chanceToWin, identities.length - 1)
+      : formatChancePct(winner.chanceToWin),
+    chanceToBestHigh: !!conclusiveWinner,
     controlColour: controlIdentity?.colour ?? '',
     controlWins: winner.isControl,
</file context>
Suggested change
chanceToBestHigh: !!conclusiveWinner,
chanceToBestHigh: winner.chanceToWin > 0.9,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is intentional. With this PR, green on the summary card and on the results table means the result is conclusive. Keeping the 90% cut-off would show a green 92% next to a banner that says there is no winner yet, which is the mixed signal #9133 is about. For a control win with many variants the figure reads "≥ 2%" because it is only a lower bound; the win itself comes from every variant being under 5%. Happy to go back to the 90% cut-off if you prefer it.

@NadyKor15

Copy link
Copy Markdown
Author

I ran an A/A simulation on main and on this PR to check the effect of the change: 10,000 simulated experiments with identical arms (10% baseline conversion, 2 arms, 30 looks of 100 new users per arm, so 3,000 per arm at the final look), using Flagsmith's unchanged stats.py and each branch's derive.ts. At the final look the banner on main named a winner in 100% of runs. With this PR it did so in 10.4% (95% CI 9.8–11.0%), in line with the roughly 10% that two one-sided 5% thresholds allow on a single look. The other three scenarios (5% or 20% baseline, or 3 arms) give 8.7–9.7%. As a sanity check, the same runs reproduce both figures reported in #9135 within their intervals.

This PR only makes the banner follow the documented 95%/5% rule. It does not address peeking: with the PR, stopping at the first named winner across the 30 looks still gives 45.8%, which is the problem raised in #9135. Stricter thresholds would lower both rates but need more data per experiment; that choice is up to the maintainers and outside this PR. Code, parameters and expected outputs are at https://github.com/NadyKor15/flagsmith-experiment-banner-evidence/tree/main/aa-simulation, and ./run.sh --flagsmith-src <path to a Flagsmith checkout> reproduces the figures in under a minute (the README lists the clone and fetch commands).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experiments: results banner declares a winner at any probability, docs say 95% / 5%

1 participant