lifetimes
lifetimes copied to clipboard
Wrong holdout monetary value
Problem
Holdout monetary value (monetary_value_holdout) calculated in calibration_and_holdout_data method in utils.py doesn't seem right and it gives very low holdout monetary values.
Why
This is probably because we are grouping the holdout period data in using CustomerID and then taking the mean of all transaction values of a customer to calculate his/her holdout monetary value. The approach used to calculate calibration monetary value is different as it groups calibration data using CustomerID and TransactionDate to find out total purchase amount for each customer on all given days and then takes its mean to calculate calibration monetary value.
Solution
Replace this code snippet with the following snippet
if monetary_value_col:
holdout_summary_data["monetary_value_holdout"] = holdout_transactions.groupby(customer_id_col)[
monetary_value_col
].mean()
if monetary_value_col:
holdout_summary_data["monetary_value_holdout"] = holdout_transactions.groupby([customer_id_col, datetime_col])[
monetary_value_col
].sum().groupby(customer_id_col).mean()
Please do let me know if I am missing anything.
This issue has been fixed in the pymc-marketing successor project.