Module model_multioptions

class prayas.model_multioptions.MultiOptionsModel(variants, options, baseline=None, priors=1)

Class for multi-options models

This model is applicable for scenarios where a trial consists of one or more options to choose from. The prior distribution of the conversion rate follows a Dirichlet(a) distribution.

Parameters
  • variants – Integer defining the number of variants or a list variant names

  • baseline – Baseline variant

  • options – List of integers or list of names defining the individual options per variant

  • priors – Hyperparameters of the prior distribution

References

“Bayesian A/B Testing for Business Decisions” by Shafi Kamalbasha and Manuel J. A. Eugster, 2020. https://arxiv.org/abs/2003.02769

add_measure(name, success_value, nonsuccess_value=None)

Method to add an additional measure

Parameters
  • name – Name of the measure, e.g., revenue

  • success_value – Value in case of success for each variant and option

  • nonsuccess_value – Value in case of nonsuccess for each variant and option

Returns

None, used for its side-effect

set_result(successes, trials)

Set the result of the experiment

Parameters
  • successes – Successes per variant and option

  • trials – Trials per variant and option

Returns

None, used for its side-effect

new(successes, trials)

Create a new ConversionModel object, used for experiments

Parameters
  • successes – Successes per variant and option

  • trials – Trials per variant and option

Returns

ConversionModel object

sample(measure=None, n=20000)

Sample from the posterior distribution of each variant

Parameters
  • measure – Name of the measure; default is conversion

  • n – Number of samples to draw

Returns

Array with samples for each variant

measure(measure=None)

Return the value of a specific measure

Parameters

measure – Name of the measure; default is conversion

Returns

Data frame with measure per variant

plot(n=20000)

Plot the posterior distribution of each variant

Parameters

n – Number of samples to draw

Returns

Matplotlib pyplot object

plot_options(measure=None, n=20000)

Plot the curves of the individual options.

Parameters
  • measure – Name of the measure; default is conversion

  • n – Number of samples to draw

Returns

Matplotlib pyplot object