lifetimes icon indicating copy to clipboard operation
lifetimes copied to clipboard

TypeError beta_geo_beta_binom_fitter.py

Open mkbldn opened this issue 6 years ago • 5 comments

Using the plotting.plot_period_transactions with a condensed RFM matrix for the BGBB fitter and received this error.

~\AppData\Local\Continuum\anaconda3\lib\site-packages\lifetimes\fitters\beta_geo_beta_binom_fitter.py in <lambda>(size)
    167         self.generate_new_data = lambda size=1: beta_geometric_beta_binom_model(
    168             # Making a large array replicating n by n_custs having n.
--> 169             np.array(sum([n_] * n_cust for (n_, n_cust) in zip(n_periods, weights))),
    170             *self._unload_params("alpha", "beta", "gamma", "delta"),
    171             size=size

TypeError: unsupported operand type(s) for +: 'int' and 'list'
Original:

np.array(sum([n_] * n_cust for (n_, n_cust) in zip(n_periods, weights))),

Updated:

np.array(sum(([n_] * n_cust for (n_, n_cust) in zip(n_periods, weights)),[])),

mkbldn avatar Mar 08 '19 17:03 mkbldn

hm, I wonder if this is a new bug (0.11+), or has always been around. What version of lifetimes, python and Pandas are you using?

CamDavidsonPilon avatar Mar 08 '19 17:03 CamDavidsonPilon

It was around in version 10 of lifetimes. I meant to mention it earlier in the week when I started fooling with the BGBB, but it just slipped my mind. I'm using 11.1 now and pandas 0.24.1.

mkbldn avatar Mar 08 '19 17:03 mkbldn

Awesome, thanks! I'll fix and write some regression tests for it

CamDavidsonPilon avatar Mar 08 '19 17:03 CamDavidsonPilon

NP. QQ for you. Are the calibration graphs meant to be used with with a BGBB model that's been trained on a condensed RFM matrix? I had to make some changes to get plot_period_transactions to behave as intended.

mkbldn avatar Mar 08 '19 18:03 mkbldn

hi quick Q on a fix for this issue?

mjconnor avatar Aug 25 '20 02:08 mjconnor