{
"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",
" Variant | \n",
" Measure | \n",
" ProbabilityToBeBest | \n",
" ProbabilityToBeatBaseline | \n",
" UpliftFromBaseline | \n",
" PotentialLossFromBaseline | \n",
" MaxUplift | \n",
" MaxPotentialLoss | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Blue | \n",
" conversion | \n",
" 0.9924 | \n",
" 1.0 | \n",
" 89.057671 | \n",
" 0.0 | \n",
" 88.963086 | \n",
" 0.017103 | \n",
"
\n",
" \n",
" 1 | \n",
" Green | \n",
" conversion | \n",
" 0.0076 | \n",
" 1.0 | \n",
" 57.726761 | \n",
" 0.0 | \n",
" 57.596831 | \n",
" 16.614105 | \n",
"
\n",
" \n",
" 2 | \n",
" Red | \n",
" conversion | \n",
" 0.0000 | \n",
" 0.0 | \n",
" 0.000000 | \n",
" 0.0 | \n",
" -36.546947 | \n",
" 47.095717 | \n",
"
\n",
" \n",
"
\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",
" Variant | \n",
" Measure | \n",
" ProbabilityToBeBest | \n",
" ProbabilityToBeatBaseline | \n",
" UpliftFromBaseline | \n",
" PotentialLossFromBaseline | \n",
" MaxUplift | \n",
" MaxPotentialLoss | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Blue | \n",
" conversion | \n",
" 0.99355 | \n",
" 1.0 | \n",
" 89.123055 | \n",
" 0.0 | \n",
" 89.117280 | \n",
" 0.017340 | \n",
"
\n",
" \n",
" 1 | \n",
" Green | \n",
" conversion | \n",
" 0.00645 | \n",
" 1.0 | \n",
" 57.717259 | \n",
" 0.0 | \n",
" 57.636056 | \n",
" 16.714971 | \n",
"
\n",
" \n",
" 2 | \n",
" Red | \n",
" conversion | \n",
" 0.00000 | \n",
" 0.0 | \n",
" 0.000000 | \n",
" 0.0 | \n",
" -36.562736 | \n",
" 47.132823 | \n",
"
\n",
" \n",
"
\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
}