pymc-marketing
pymc-marketing copied to clipboard
Issues with pymc_marketing.plot_frequency_recency_matrix()
I installed the latest version of pymc-marketing via Miniconda on a MacOS M2. While running the CLV Quickstart notebook, I'm getting the following error:
1.2.1. Visualizing the Frequency/Recency Matrix
clv.plot_frequency_recency_matrix(bgm);
AttributeError Traceback (most recent call last) Cell In[12], line 1 ----> 1 clv.plot_frequency_recency_matrix(bgm)
File ~/miniconda3/envs/marketing_env/lib/python3.11/site-packages/pymc_marketing/clv/plotting.py:200, in plot_frequency_recency_matrix(model, t, max_frequency, max_recency, title, xlabel, ylabel, ax, **kwargs) 169 """ 170 Plot recency frequency matrix as heatmap. 171 Plot a figure of expected transactions in T next units of time by a customer's frequency and recency. (...) 197 axes: matplotlib.AxesSubplot 198 """ 199 if max_frequency is None: --> 200 max_frequency = int(model.frequency.max()) 202 if max_recency is None: 203 max_recency = int(model.recency.max())
AttributeError: 'BetaGeoModel' object has no attribute 'frequency'
What am I doing wrong?
Hey @gdberrio,
You did nothing wrong - in fact, thanks for sharing the error trace, as it made this issue really easy to diagnose: There were some significant internal changes made to the CLV models last week, and the model.frequency attribute was renamed to model.data["recency"]. We didn't catch this because the plotting module is being tested with a mocked model, which wasn't updated to reflect the changes.
Looks like we'll need to update the attribute references in the plotting module, as well as that mocked test. I'm planning to add some new plotting functions within the next few weeks, and can roll this fix into that PR.
So, which version can I install to prevent this until you guys fix this?
Try 0.3.2
Yep tks. 0.3.2 works.
Just opened a PR because I decided broken functionality like this should be given top priority.