Skip to content

Instantly share code, notes, and snippets.

@meraldo-aliz
Created March 2, 2022 05:45
Show Gist options
  • Save meraldo-aliz/b6c14945922570ff69cc33c28f03d672 to your computer and use it in GitHub Desktop.
Save meraldo-aliz/b6c14945922570ff69cc33c28f03d672 to your computer and use it in GitHub Desktop.
lifetimes
# the real number of transactions in the observation period, which equals frequency_holdout + 1
rfm_cal_holdout["n_transactions_holdout_real"] = rfm_cal_holdout["frequency_holdout"] + 1
# the predicted number of transactions in the next 26 weeks (length of the observation period)
rfm_cal_holdout["n_transactions_holdout_pred"] = bgf.predict(t=26,
frequency=rfm_cal_holdout['frequency_cal'],
recency=rfm_cal_holdout['recency_cal'],
T=rfm_cal_holdout['T_cal'])
# comparison of the real and predicted transactions
rfm_cal_holdout[["n_transactions_holdout_real", "n_transactions_holdout_pred"]].head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment