Closed swasthikshettyhcl closed 5 days ago
time_days = 126 time_months = int(math.ceil(time_days / 30.0))
summary = f_and_t[['customer_id', 'frequency_btyd', 'recency', 'T', 'monetary_btyd']]
summary.columns = ['customer_id', 'frequency', 'recency', 'T', 'monetary_value'] summary = summary.set_index('customer_id')
actual_df = f_and_t[['customer_id', 'frequency_btyd', 'monetary_dnn', 'target_monetary']] actual_df.columns = ['customer_id', 'train_frequency', 'train_monetary', 'act_target_monetary']
paretof = ParetoNBDFitter(penalizer_coef= 0.01) paretof.fit(summary['frequency'], summary['recency'], summary['T'])
ggf = GammaGammaFitter(penalizer_coef=0) ggf.fit(summary['frequency'], summary['monetary_value'])
pareto_pred = paretof.predict(time_days, summary['frequency'].values, summary['recency'], summary['T'])
trans_pred = pareto_pred.fillna(0)
predicted_value = ggf.customer_lifetime_value(paretof, summary['frequency'],#.values, summary['recency'], summary['T'], summary['monetary_value'], time=time_months, discount_rate= 0.01)
I was using the lifetimes library to calculate CLV for a list of customers. The error below appears for both functions: paretof.predict and ggf.customer_lifetime_value. For paretof. but it works fine with BG/NBD.
I already found posts to this issue, from (https://stackoverflow.com/questions/69071130/lifetimes-library-issue-of-calculating-clv-when-using-function-customer-lifet). The solution to use ".values" only worked for the paretof.predict function. At the ggf.customer_lifetime_value function I am stuck.
Hello! This repo is deprecated, consider using pymc's project
thanks
time_days = 126 time_months = int(math.ceil(time_days / 30.0))
column-selection
summary = f_and_t[['customer_id', 'frequency_btyd', 'recency', 'T', 'monetary_btyd']]
summary.columns = ['customer_id', 'frequency', 'recency', 'T', 'monetary_value'] summary = summary.set_index('customer_id')
actual_df = f_and_t[['customer_id', 'frequency_btyd', 'monetary_dnn', 'target_monetary']] actual_df.columns = ['customer_id', 'train_frequency', 'train_monetary', 'act_target_monetary']
PARETO/NBD fitter
paretof = ParetoNBDFitter(penalizer_coef= 0.01) paretof.fit(summary['frequency'], summary['recency'], summary['T'])
Gamma Gamma Fitter
ggf = GammaGammaFitter(penalizer_coef=0) ggf.fit(summary['frequency'], summary['monetary_value'])
pareto predict
pareto_pred = paretof.predict(time_days, summary['frequency'].values, summary['recency'], summary['T'])
trans_pred = pareto_pred.fillna(0)
gg predict
predicted_value = ggf.customer_lifetime_value(paretof, summary['frequency'],#.values, summary['recency'], summary['T'], summary['monetary_value'], time=time_months, discount_rate= 0.01)
Issue Description
I was using the lifetimes library to calculate CLV for a list of customers. The error below appears for both functions: paretof.predict and ggf.customer_lifetime_value. For paretof. but it works fine with BG/NBD.
I already found posts to this issue, from (https://stackoverflow.com/questions/69071130/lifetimes-library-issue-of-calculating-clv-when-using-function-customer-lifet). The solution to use ".values" only worked for the paretof.predict function. At the ggf.customer_lifetime_value function I am stuck.