CamDavidsonPilon / lifetimes

Lifetime value in Python
MIT License
1.45k stars 373 forks source link

BUG: Cannot apply ufunc <ufunc 'hyp2f1'> to mixed DataFrame and Series inputs. #452

Closed swasthikshettyhcl closed 5 days ago

swasthikshettyhcl commented 5 days ago

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.

CamDavidsonPilon commented 5 days ago

Hello! This repo is deprecated, consider using pymc's project

swasthikshettyhcl commented 5 days ago

thanks