Abstract class defining predictive methods for all models except GammaGamma.
In research literature these are commonly referred to as quantities of interest.
These are internal methods and not intended to be called directly.
Docstrings for each method are provided in respective model subclass.
method (str) – Predictive quantity of interest; accepts ‘cond_prob_alive’, ‘cond_n_prchs_to_time’,’n_prchs_to_time’, or ‘prob_n_prchs_to_time’.
rfm_df (pandas.DataFrame) – Dataframe containing recency, frequency, monetary value, and time period columns.
t (int) – Number of time periods for predictions.
n (int) – Number of transactions predicted.
sample_posterior (bool) – Flag for sampling from parameter posteriors. Set to ‘True’ to return predictive probability distributions instead of point estimates.
posterior_draws (int) – Number of draws from parameter posteriors.
join_df (bool) – NOT SUPPORTED IN 0.1beta2. Flag to add columns to rfm_df containing predictive outputs.
Returns:
predictions – Numpy arrays containing predictive quantities of interest.
Also known as the BG/NBD model.
Based on [1], this model has the following assumptions:
1) Each individual, i, has a hidden lambda_i and p_i parameter
2) These come from a population wide Gamma and a Beta distribution respectively.
3) Individuals purchases follow a Poisson process with rate \(\lambda_i*t\) .
4) After each purchase, an individual has a p_i probability of dieing (never buying again).
Parameters:
hyperparams (dict) – Dictionary containing hyperparameters for model prior parameter distributions.
Based on [5], [6], this model has the following assumptions:
1) Each individual, i, has a hidden lambda_i and p_i parameter
2) These come from a population wide Gamma and a Beta distribution
respectively.
Individuals purchases follow a Poisson process with rate \(\lambda_i*t\) .
At the beginning of their lifetime and after each purchase, an
individual has a p_i probability of dieing (never buying again).
Parameters:
hyperparams (dict) – Dictionary containing hyperparameters for model prior parameter distributions.
Base method for running Gamma-Gamma model predictions.
Parameters:
method (str) – Predictive quantity of interest; accepts ‘avg_value’ or ‘clv’.
rfm_df (pandas.DataFrame) – Dataframe containing recency, frequency, monetary value, and time period columns.
sample_posterior (bool) – Flag for sampling from parameter posteriors. Set to ‘True’ to return predictive probability distributions instead of point estimates.
posterior_draws (int) – Number of draws from parameter posteriors.
join_df (bool) – NOT SUPPORTED IN 0.1beta2. Flag to add columns to rfm_df containing predictive outputs.
transaction_prediction_model (btyd.models) – the model to predict future transactions, literature uses pareto/ndb models but we can also use a different model like beta-geo models
time (float, optional) – the lifetime expected for the user in months. Default: 12