pymc-marketing
pymc-marketing copied to clipboard
RFM Segmentation
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
- [x] Checked that the pre-commit linting/style checks pass
- [x] Included tests that prove the fix is effective or that the new feature works
- [x] Added necessary documentation (docstrings and/or example notebooks)
- [x] If you are a pro: each commit corresponds to a relevant logical change
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/
Check out this pull request on ![]()
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.
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.
In a different PR we can tackle the example notebook and maybe add som plots on how to evaluate and understand these segments
I'm confused about this Codecov report, because
pytest-covreports 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 ¯\(ツ)/¯.
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.
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 ;)
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.
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 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 :)