btyd icon indicating copy to clipboard operation
btyd copied to clipboard

btyd.fitters.BaseFitter._fit() got multiple values for keyword argument 'bounds'

Open Username159 opened this issue 1 year ago • 1 comments

Hi,

I want to pass custom bound values to the scipy.optimize.minimuze function in the GammaGammaFitter.fit() function, but I get the following error: btyd.fitters.BaseFitter._fit() got multiple values for keyword argument 'bounds'.

A small, simplified example to replicate this error would be:

from btyd import BetaGeoFitter
from btyd import GammaGammaFitter

from lifetimes.datasets import load_cdnow_summary_data_with_monetary_value

df_parsed = load_cdnow_summary_data_with_monetary_value()
returning_customers_summary = df_parsed[df_parsed["frequency"] != 0]
model = BetaGeoFitter()
model.fit(
    frequency=df_parsed["frequency"], 
    recency=df_parsed["recency"], 
    T=df_parsed["T"]
)
print(model.summary)

gg_model = GammaGammaFitter(penalizer_coef=1e-2)
gg_model.fit(
    frequency=returning_customers_summary["frequency"],
    monetary_value=returning_customers_summary["monetary_value"],
    bounds=((None, None), (0.00996, None), (None, None))
)

I need this feature to avoid problems with GammaGammaFitter.conditional_expected_average_profit() and GammaGammaFitter.customer_lifetime_value(). For my data I need a higher penalizer_coef which results in a q smaller than 1. Which then leads to negative CLV outputs. When I set q_constraint = True (meaning bounds=((None, None), (0.0, None), (None, None))) , I get q=1.0 as a parameter, which leads to nan values in GammaGammaFitter.conditional_expected_average_profit() and GammaGammaFitter.customer_lifetime_value(), so I want to "force" q to be bigger than 1.0 with custom bounds.

Username159 avatar Apr 24 '23 11:04 Username159