1

I am doing customer value prediction using lifetimes package. I am unable to run the lifetimes.GammaGammaFitter model. It is showing Unexpected exception formatting exception. Falling back to standard exception when running it.

The dataframe looks like below

 return_customers_summary.head()

  WH_PLAYER_ID    frequency   recency     T   monetary_value    pred_num_txn
  10130001022      1.0         17.0     61.0     6.251061         1.0
  10130001057      60.0        69.0     70.0     0.955752         25.0
  10130001028      1.0         9.0      69.0     0.000000         0.0

When I try to run the Gamma Gamma model, I am getting the following error

ggf = lifetimes.GammaGammaFitter(penalizer_coef = 0.001)

ggf.fit(return_customers_summary['frequency'], return_customers_summary['monetary_value'])


Unexpected exception formatting exception. Falling back to standard exception.



Traceback (most recent call last):
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "C:\Users\subven\AppData\Local\Temp\ipykernel_17176\2939325914.py", line 5, in <cell line: 5>
    ggf.fit(return_customers_summary['frequency'],
  File "C:\Users\subven\Anaconda3\lib\site-packages\lifetimes\fitters\gamma_gamma_fitter.py", line 214, in fit
  File "C:\Users\subven\Anaconda3\lib\site-packages\lifetimes\utils.py", line 444, in _check_inputs
ValueError: There exist non-positive (<= 0) values in the monetary_value vector.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 1982, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1118, in structured_traceback
    return FormattedTB.structured_traceback(
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1012, in structured_traceback
    return VerboseTB.structured_traceback(
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 865, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 818, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "C:\Users\subven\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 736, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\core.py", line 698, in lines
    pieces = self.included_pieces
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\subven\Anaconda3\lib\site-packages\stack_data\core.py", line 628, in executing_piece
    return only(
  File "C:\Users\subven\Anaconda3\lib\site-packages\executing\executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0
desertnaut
  • 57,590
  • 26
  • 140
  • 166
venkat
  • 13
  • 2

0 Answers0