Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(experiments): compare the winning variant with the second best variant #21254

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions frontend/src/scenes/experiments/ExperimentView/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ export function Overview(): JSX.Element {
experimentResults,
getIndexForVariant,
experimentInsightType,
sortedConversionRates,
getHighestProbabilityVariant,
areResultsSignificant,
conversionRateForVariant,
} = useValues(experimentLogic)

function WinningVariantText(): JSX.Element {
const winningVariant = getHighestProbabilityVariant(experimentResults)

if (experimentInsightType === InsightType.FUNNELS) {
const winningConversionRate = conversionRateForVariant(experimentResults, winningVariant || '')
const controlConversionRate = conversionRateForVariant(experimentResults, 'control')
const difference = parseFloat(winningConversionRate) - parseFloat(controlConversionRate)
const winningVariant = sortedConversionRates[0]
const secondBestVariant = sortedConversionRates[1]
const difference = winningVariant.conversionRate - secondBestVariant.conversionRate

if (difference === 0) {
if (winningVariant.conversionRate === secondBestVariant.conversionRate) {
return (
<span>
<b>No variant is winning</b> at this moment.&nbsp;
Expand All @@ -35,28 +33,29 @@ export function Overview(): JSX.Element {

return (
<div className="items-center inline-flex flex-wrap">
<VariantTag variantKey={winningVariant || ''} />
<VariantTag variantKey={winningVariant.key} />
<span>&nbsp;is winning with a conversion rate&nbsp;</span>
<span className="font-semibold text-success items-center">
increase of {`${difference.toFixed(2)}%`}
</span>
<span>&nbsp;percentage points (vs&nbsp;</span>
<VariantTag variantKey="control" />
<VariantTag variantKey={secondBestVariant.key} />
<span>).&nbsp;</span>
</div>
)
}

const index = getIndexForVariant(experimentResults, winningVariant || '')
if (winningVariant && index !== null && experimentResults) {
const highestProbabilityVariant = getHighestProbabilityVariant(experimentResults)
const index = getIndexForVariant(experimentResults, highestProbabilityVariant || '')
if (highestProbabilityVariant && index !== null && experimentResults) {
const { probability } = experimentResults

return (
<div className="items-center inline-flex flex-wrap">
<VariantTag variantKey={winningVariant} />
<VariantTag variantKey={highestProbabilityVariant} />
<span>&nbsp;is winning with a&nbsp;</span>
<span className="font-semibold text-success items-center">
{`${(probability[winningVariant] * 100).toFixed(2)}% probability`}&nbsp;
{`${(probability[highestProbabilityVariant] * 100).toFixed(2)}% probability`}&nbsp;
</span>
<span>of being best.&nbsp;</span>
</div>
Expand Down
Loading