{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# One option vs. multi-options model" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from prayas import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The one-option model is a special case of the multi-options model. This notebook demonstrates this on a simple example." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Models" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We define a **one option model** with three variants:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "m1 = OneOptionModel([\"Red\", \"Green\", \"Blue\"], baseline=\"Red\")\n", "\n", "m1.set_result(successes=[209, 330, 408],\n", " trials=[236113, 236108, 243241])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We define a **multi-options model** with the same setup but with only one option per variant:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "m2 = MultiOptionsModel([\"Red\", \"Green\", \"Blue\"], [1, 1, 1], baseline=\"Red\")\n", "\n", "m2.set_result(successes=[[209], [330], [408]], \n", " trials=[236113, 236108, 243241])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Comparison" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
VariantMeasureProbabilityToBeBestProbabilityToBeatBaselineUpliftFromBaselinePotentialLossFromBaselineMaxUpliftMaxPotentialLoss
0Blueconversion0.99241.089.0576710.088.9630860.017103
1Greenconversion0.00761.057.7267610.057.59683116.614105
2Redconversion0.00000.00.0000000.0-36.54694747.095717
\n", "
" ], "text/plain": [ " Variant Measure ProbabilityToBeBest ProbabilityToBeatBaseline \\\n", "0 Blue conversion 0.9924 1.0 \n", "1 Green conversion 0.0076 1.0 \n", "2 Red conversion 0.0000 0.0 \n", "\n", " UpliftFromBaseline PotentialLossFromBaseline MaxUplift MaxPotentialLoss \n", "0 89.057671 0.0 88.963086 0.017103 \n", "1 57.726761 0.0 57.596831 16.614105 \n", "2 0.000000 0.0 -36.546947 47.095717 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m1.score_baseline()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
VariantMeasureProbabilityToBeBestProbabilityToBeatBaselineUpliftFromBaselinePotentialLossFromBaselineMaxUpliftMaxPotentialLoss
0Blueconversion0.993551.089.1230550.089.1172800.017340
1Greenconversion0.006451.057.7172590.057.63605616.714971
2Redconversion0.000000.00.0000000.0-36.56273647.132823
\n", "
" ], "text/plain": [ " Variant Measure ProbabilityToBeBest ProbabilityToBeatBaseline \\\n", "0 Blue conversion 0.99355 1.0 \n", "1 Green conversion 0.00645 1.0 \n", "2 Red conversion 0.00000 0.0 \n", "\n", " UpliftFromBaseline PotentialLossFromBaseline MaxUplift MaxPotentialLoss \n", "0 89.123055 0.0 89.117280 0.017340 \n", "1 57.717259 0.0 57.636056 16.714971 \n", "2 0.000000 0.0 -36.562736 47.132823 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m2.score_baseline()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see that the results are basically the same." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }