pymc-marketing icon indicating copy to clipboard operation
pymc-marketing copied to clipboard

RFM Segmentation

Open ColtAllen opened this issue 1 year ago • 5 comments
trafficstars

Description

This PR adds the RFM segmentation functionality described in the recent CLV webinar. This article is a good deep dive into how the segmentation is performed.

There are two TODOs left in clv.utils.rfm_segments I'm interested in getting some feedback on, but they're quite minor. The dev notebook used for testing could also be expanded into a tutorial in the future, but we'll leave that for another PR as there are some plotting methods I wish to add first.

Related Issue

  • [x] Closes # https://github.com/pymc-labs/pymc-marketing/issues/523
  • [ ] Related to #

Checklist

Modules affected

  • [ ] MMM
  • [x] CLV

Type of change

  • [x] New feature / enhancement
  • [ ] Bug fix
  • [ ] Documentation
  • [ ] Maintenance
  • [ ] Other (please specify):

📚 Documentation preview 📚: https://pymc-marketing--680.org.readthedocs.build/en/680/

ColtAllen avatar May 11 '24 19:05 ColtAllen

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Codecov Report

Attention: Patch coverage is 8.82353% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 33.22%. Comparing base (0e6ce83) to head (763060b). Report is 1 commits behind head on main.

:exclamation: Current head 763060b differs from pull request most recent head 91e22b3

Please upload reports for the commit 91e22b3 to get more accurate results.

Files Patch % Lines
pymc_marketing/clv/utils.py 8.82% 31 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #680       +/-   ##
===========================================
- Coverage   92.48%   33.22%   -59.27%     
===========================================
  Files          24       24               
  Lines        2490     2519       +29     
===========================================
- Hits         2303      837     -1466     
- Misses        187     1682     +1495     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 11 '24 19:05 codecov[bot]

I'm confused about this Codecov report, because pytest-cov reports 100% code coverage in my IDE and many of the code lines in that report aren't even relevant to this PR.

ColtAllen avatar May 11 '24 20:05 ColtAllen

In a different PR we can tackle the example notebook and maybe add som plots on how to evaluate and understand these segments

juanitorduz avatar May 13 '24 07:05 juanitorduz

I'm confused about this Codecov report, because pytest-cov reports 100% code coverage in my IDE and many of the code lines in that report aren't even relevant to this PR.

Unfortunately, I do not understand why this is happening either :( . Maybe once so add the missing parts of this PR it will come back ¯\(ツ)/¯.

juanitorduz avatar May 13 '24 07:05 juanitorduz

Still need to add a test or two and address https://github.com/pymc-labs/pymc-marketing/issues/697, which may necessitate some refactoring to allow users to use their own segmentation methods. Might even roll https://github.com/pymc-labs/pymc-marketing/pull/698 into this too depending on timing.

ColtAllen avatar May 27 '24 18:05 ColtAllen

Maybe we can leave out https://github.com/pymc-labs/pymc-marketing/pull/698 as the PR is open and we are just missing some tests. It should not be a blocker for this one ;)

juanitorduz avatar May 27 '24 18:05 juanitorduz

Maybe we can leave out #698 as the PR is open and we are just missing some tests. It should not be a blocker for this one ;)

Extra tests are unnecessary; just needed to rename a column in the small dataset used for testing. The entire fix took five minutes.

ColtAllen avatar May 28 '24 01:05 ColtAllen

Also added a test and warning if only 2 bins are created. This is unlikely unless dealing with very small and/or invalid datasets that a model probably wouldn't converge on anyway, but nonetheless a custom segment config would be required.

ColtAllen avatar May 28 '24 02:05 ColtAllen

@ColtAllen Would you mind if we merge https://github.com/pymc-labs/pymc-marketing/pull/698 and then you do a small rebase? We wanna make sure we welcome contributions from everyone :)

juanitorduz avatar May 28 '24 09:05 juanitorduz