Module model_aggregate

class prayas.model_aggregate.AggregateModel(variants, baseline=None, prior_alpha=1, prior_beta=1)

Class for aggregated models

This model is applicable for scenarios where a only the aggregated measures other than conversion (e.g., revenue) are observed. The prior distribution of the measure follows an Exponential(l) distribution with the assumpition that the parameter l follows a Gamma(a, b) distribution.

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

  • baseline – Baseline variant

  • prior_alpha – Hyperparameter a of the prior distribution

  • prior_beta – Hyperparameter b 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(measure=None, n=20000)

Plot the posterior distribution of each variant

Parameters

n – Number of samples to draw

Returns

Matplotlib pyplot object