Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFM Segmentation #680

Merged
merged 24 commits into from
May 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f022c60
init rfm_segments func
ColtAllen Apr 29, 2024
592a2a4
TODOs
ColtAllen Apr 29, 2024
b2de3eb
Merge branch 'pymc-labs:main' into rfm_segment
ColtAllen May 1, 2024
d653915
docstrings and for loop
ColtAllen May 1, 2024
199ad46
docstrings and for loop
ColtAllen May 1, 2024
3c4f684
Merge branch 'rfm_segment' of https://github.com/ColtAllen/pymc-marke…
ColtAllen May 1, 2024
aa5f871
WIP dev notebook debugging
ColtAllen May 2, 2024
e1fdc93
Merge branch 'pymc-labs:main' into rfm_segment
ColtAllen May 4, 2024
e5f112a
Merge branch 'pymc-labs:main' into rfm_segment
ColtAllen May 10, 2024
bea0bbd
checkpoint commit for remote pull
ColtAllen May 10, 2024
7cda576
Merge branch 'rfm_segment' of https://github.com/ColtAllen/pymc-marke…
ColtAllen May 10, 2024
00c58c5
code testing in dev notebook
ColtAllen May 10, 2024
bcc7274
unit tests added
ColtAllen May 11, 2024
210c245
dev notebook cleanup
ColtAllen May 11, 2024
798eb3b
Merge branch 'pymc-labs:main' into rfm_segment
ColtAllen May 26, 2024
eca910d
clean up type hints
ColtAllen May 27, 2024
2cfae06
comments and code cleanup
ColtAllen May 27, 2024
2d685e5
docstrings
ColtAllen May 27, 2024
763060b
move formatting to rfm_summary and quickstart edits
ColtAllen May 28, 2024
9710df5
fix rfm_train_test_split bug
ColtAllen May 28, 2024
e18d0c6
Merge branch 'pymc-labs:main' into rfm_segment
ColtAllen May 28, 2024
62caf94
added test for rfm_quartile_labels
ColtAllen May 28, 2024
93fb6f9
added rfm score warning
ColtAllen May 28, 2024
91e22b3
Merge branch 'main' into rfm_segment
ColtAllen May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit tests added
  • Loading branch information
ColtAllen committed May 11, 2024

Verified

This commit was signed with the committer’s verified signature.
kislyuk Andrey Kislyuk
commit bcc7274fa4c2bfb9bce1c3cab5b5ddb8a631dd0d
33 changes: 32 additions & 1 deletion tests/clv/test_utils.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
_find_first_transactions,
clv_summary,
customer_lifetime_value,
rfm_segments,
rfm_summary,
rfm_train_test_split,
to_xarray,
@@ -849,4 +850,34 @@ def test_rfm_train_test_split_with_monetary_value(self, transaction_data):
assert (actual["monetary_value"] == [0, 0, 3, 0, 4.5]).all()
assert (actual["test_monetary_value"] == [2, 0, 0, 6, 0]).all()

# check test_monetary_value is being aggregated correctly for time periods with multiple purchases
@pytest.mark.parametrize("config", (None, "custom"))
def test_rfm_segmentation_config(self, transaction_data, config):
if config is not None:
config = {
"Test Segment": [
"111",
"222",
"333",
"444",
]
}
expected = ["Other", "Test Segment", "Other", "Other", "Other", "Other"]
else:
expected = [
"Other",
"Inactive Customer",
"At Risk Customer",
"Premium Customer",
"Repeat Customer",
"Top Spender",
]

actual = rfm_segments(
transaction_data,
"id",
"date",
"monetary_value",
segment_config=config,
)

assert (actual["segment"] == expected).all()
ColtAllen marked this conversation as resolved.
Show resolved Hide resolved