docs: add analysis module examples#113
Conversation
WalkthroughThis pull request updates the documentation and public API definitions. The documentation in Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
docs/analysis_modules.md (3)
62-65: Clarify Histogram Description Text.
The revised description explains how histograms visualize data distributions and group comparisons well. Consider a brief rephrasing to enhance readability (e.g., breaking up the long sentence) but overall it is clear.
621-626: Clarify Segmentation Stats Description and Punctuation.
The comprehensive description for the Segmentation Stats module is effective. Note that around line 625 there may be a missing comma; please review the sentence for proper punctuation to maximize clarity.🧰 Tools
🪛 LanguageTool
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...(AI_HYDRA_LEO_MISSING_COMMA)
662-668: Correct Typo in Purchases Per Customer Description.
The module description is informative; however, the word “deteriming” on line 667 appears to be a typo. It should be corrected to “determining” to ensure clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
docs/assets/images/analysis_modules/cross_shop.svgis excluded by!**/*.svgdocs/assets/images/analysis_modules/days_between_purchases.svgis excluded by!**/*.svgdocs/assets/images/analysis_modules/gain_loss.svgis excluded by!**/*.svgdocs/assets/images/analysis_modules/purchases_per_customer.svgis excluded by!**/*.svgdocs/assets/images/analysis_modules/transaction_churn.svgis excluded by!**/*.svg
📒 Files selected for processing (1)
docs/analysis_modules.md(5 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/analysis_modules.md
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...
(AI_HYDRA_LEO_MISSING_COMMA)
[grammar] ~727-~727: The verb form ‘reveal’ does not appear to fit in this context.
Context: ... of purchases customers have made. This help reveal critical retention thresholds in the cu...
(SINGULAR_NOUN_VERB_AGREEMENT)
🔇 Additional comments (8)
docs/analysis_modules.md (8)
73-74: Review Customization Options Description.
The added text describing customizable legends, axes, and clipping options provides useful detail. The language is consistent with other sections.
114-117: Verify Bar Plot Description Clarity.
The updated description clearly covers grouping, stacking, and the ability to add data labels for bar plots. Minor wording adjustments could be considered for uniformity across sections, but the overall message is clear.
125-126: Check Consistency in Bar Plot Flexibility Description.
The text emphasizing flexibility in customizing legends and axes is clear and matches the style used in other plot sections.
355-368: Enhance Cross Shop Section Description.
The new Cross Shop module details—including the image and descriptive text—provide a clear overview of how Venn/Euler diagrams illustrate cross-purchasing behavior. It may be beneficial to note (or link to) any specific input data requirements if not documented elsewhere.
397-406: Review Gain Loss Module Description.
The explanation concisely outlines the key aspects of the Gain Loss analysis, with a clear bullet list that aids comprehension. Ensure terms like “Switching” are defined or linked to further details for new users.
443-445: Validate Image Path for Customer Decision Hierarchy.
The image inclusion for the Customer Decision Hierarchy is correctly formatted with proper attributes. Double-check the asset path and dimensions to ensure they align with design guidelines.
518-520: Confirm Revenue Tree Date Filters.
The updated example for the Revenue Tree module now uses clear date-based filters. Please verify that the cutoff dates accurately reflect the intended analysis period in production.
690-704: Assess Days Between Purchases Module Description.
The detailed explanation in this section effectively outlines the module’s benefits and uses clear bullet points. Verify that terms like “cumulative” (if used elsewhere) are consistently spelled throughout the document.
| {align=right loading=lazy width="50%"} | ||
|
|
||
| PASTE TEXT HERE | ||
| The Transaction Churn module analyzes how customer churn rates vary based on the number of purchases customers have | ||
| made. This help reveal critical retention thresholds in the customer lifecycle when setting a churn window | ||
|
|
There was a problem hiding this comment.
Fix Grammatical Agreement in Transaction Churn Description.
The sentence "This help reveal critical retention thresholds" should be revised to "This helps reveal critical retention thresholds" to ensure correct subject–verb agreement.
🧰 Tools
🪛 LanguageTool
[grammar] ~727-~727: The verb form ‘reveal’ does not appear to fit in this context.
Context: ... of purchases customers have made. This help reveal critical retention thresholds in the cu...
(SINGULAR_NOUN_VERB_AGREEMENT)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
docs/analysis_modules.md (3)
621-626: Solid Overview for Segmentation Stats
The added description for the Segmentation Stats module provides a concise summary of the metrics calculated by the module. For clarity, consider rephrasing “customer (or transactions or promotions) groups” into a more explicit enumeration.🧰 Tools
🪛 LanguageTool
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...(AI_HYDRA_LEO_MISSING_COMMA)
734-743: Typo in Transaction Churn Example Code
There is a minor typo in the parameter name: cumlative should be cumulative to correctly reflect its intent. Consider applying the following diff:- cumlative=True, + cumulative=True,
625-626: Suggestion: Add a Comma for Clarity
Static analysis tools flagged a potential missing comma around here. To improve readability, consider adding a comma before “like HML segmentation” in the sentence within the Segmentation Stats section.🧰 Tools
🪛 LanguageTool
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...(AI_HYDRA_LEO_MISSING_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/analysis_modules.md(5 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/analysis_modules.md
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (10)
docs/analysis_modules.md (10)
62-65: Clear and Informative Histogram Description
The added text clearly explains how histograms visualize data distributions and support grouping. The description is detailed and enhances reader understanding.
73-74: Concise Customization Details
The explanation of customization options for legends, axes, and filtering is clear and useful. Great job outlining these features!
114-117: Enhanced Bar Plot Explanation
The revised text for bar plots effectively describes how metrics can be compared and how data labels are applied. The clarity in detailing grouping and stacking options is commendable.
355-360: Comprehensive Cross Shop Section
The new Cross Shop section now includes an illustrative image and a precise description of its functionality. This addition makes it easier for users to grasp how cross-purchasing behavior is visualized.
397-408: Detailed Gain Loss Module Explanation
The Gain Loss section now features an image and a well-structured breakdown of customer behavior changes (new, lost, spending changes, and switching). The step‐by‐step list is clear and beneficial for users.
443-445: Effective Customer Decision Hierarchy Image Inclusion
The inclusion of the image for the Customer Decision Hierarchy (CDH) with proper alignment and loading attributes improves visual appeal and clarity.
518-519: Revenue Tree Example Update
The updated example for the Revenue Tree module now clearly differentiates between the two transaction periods using date filters. Please verify that the selected date ranges align with the analytics requirements.
662-664: Appropriate Purchases Per Customer Image Integration
The image for the Purchases Per Customer module is correctly integrated with clear alignment and lazy loading. This enhances the aesthetics and readability of the section.
690-692: Well-Handled Days Between Purchases Image
The inclusion of the Days Between Purchases image with proper formatting and alignment effectively supports the content. It contributes to a better visual understanding of the module.
724-728: Accurate Transaction Churn Description
The Transaction Churn section now correctly uses “helps reveal” rather than “help reveal,” ensuring grammatical accuracy. The description and image integration effectively communicate the module’s purpose.
There was a problem hiding this comment.
PR Overview
This PR updates the documentation for analysis modules by adding new examples and enhancing existing content for clarity and readability.
- Added detailed usage examples for modules like Cross Shop, Gain Loss, Customer Decision Hierarchy, Purchases Per Customer, Days Between Purchases, and Transaction Churn.
- Improved image and code snippet formatting for better visual presentation and consistency.
Reviewed Changes
| File | Description |
|---|---|
| docs/analysis_modules.md | Updated example content and markdown formatting to improve clarity and readability. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
|
|
||
| tc.plot( | ||
| title="Churn Rate by Number of Purchases", | ||
| cumlative=True, |
There was a problem hiding this comment.
Typo detected: 'cumlative' should be corrected to 'cumulative'.
| cumlative=True, | |
| cumulative=True, |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/analysis_modules.md (1)
621-627: Well-written documentation for the Segmentation Stats module.The new Segmentation Stats section clearly explains the purpose and functionality of the module.
Consider adding a comma after "approaches" in the following sentence:
-This module calculates metrics such as total spend, number of transactions, average spend per customer, and transactions per customer for each segment. It's particularly useful when combined with other segmentation approaches like HML segmentation. +This module calculates metrics such as total spend, number of transactions, average spend per customer, and transactions per customer for each segment. It's particularly useful when combined with other segmentation approaches, like HML segmentation.🧰 Tools
🪛 LanguageTool
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...(AI_HYDRA_LEO_MISSING_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
README.md(1 hunks)docs/analysis_modules.md(5 hunks)docs/examples/retention.ipynb(2 hunks)pyretailscience/customer.py(11 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/examples/retention.ipynb
🧰 Additional context used
🪛 GitHub Check: codecov/patch
pyretailscience/customer.py
[warning] 91-91: pyretailscience/customer.py#L91
Added line #L91 was not covered by tests
[warning] 268-268: pyretailscience/customer.py#L268
Added line #L268 was not covered by tests
🪛 LanguageTool
docs/analysis_modules.md
[uncategorized] ~625-~625: Possible missing comma found.
Context: ...l when combined with other segmentation approaches like HML segmentation. Example...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (20)
README.md (1)
111-111: Parameter name spelling fix correctly applied.The parameter name has been correctly updated from
cumlativetocumulative, ensuring consistency with the underlying API changes in thecustomer.pyfile.pyretailscience/customer.py (8)
46-46: Parameter name spelling correction in PurchasesPerCustomer class.The parameter name has been correctly updated from
cumlativetocumulativein both the method signature and docstring.Also applies to: 59-59
73-74: Consistent parameter usage in conditional logic and method call.The parameter name has been properly updated in both the conditional check and the method call to
hist().Also applies to: 81-81
90-92: Parameter name spelling correction in title logic.The conditional check and default title logic now correctly use the
cumulativeparameter name.The line is flagged as not covered by tests. Consider adding a test case that exercises the cumulative plotting functionality to ensure complete coverage.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 91-91: pyretailscience/customer.py#L91
Added line #L91 was not covered by tests
224-224: Parameter name spelling correction in DaysBetweenPurchases class.The parameter name has been correctly updated from
cumlativetocumulativein both the method signature and docstring.Also applies to: 237-237
251-252: Consistent parameter usage in conditional logic and method call.The parameter name has been properly updated in both the conditional check and the method call to
hist().Also applies to: 256-256
267-268: Parameter name spelling correction in title logic.The conditional check and default title logic now correctly use the
cumulativeparameter name.The line is flagged as not covered by tests. Consider adding a test case that exercises the cumulative plotting functionality to ensure complete coverage.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 268-268: pyretailscience/customer.py#L268
Added line #L268 was not covered by tests
373-373: Parameter name spelling correction in TransactionChurn class.The parameter name has been correctly updated from
cumlativetocumulativein both the method signature and docstring.Also applies to: 384-384
395-396: Consistent parameter usage in conditional logic.The parameter name has been properly updated in the conditional check that determines the plotting behavior.
docs/analysis_modules.md (11)
355-371: Well-structured documentation for the Cross Shop module.The new Cross Shop section provides clear explanations of the module's functionality, applications, and usage. The example code demonstrates the correct API usage with appropriate parameter names.
397-437: Comprehensive documentation for the Gain Loss module.The Gain Loss section effectively explains the module's purpose, key components, and practical applications. The example code is clear and demonstrates proper API usage.
518-520: Updated example code for the Revenue Tree module.The example code for the Revenue Tree module has been updated with more realistic parameter values.
633-648: Clear example code for the Segmentation Stats module.The example code effectively demonstrates how to use the SegTransactionStats class with an HML segmentation.
650-656: Helpful example output table for Segmentation Stats.The example output table clearly shows what kind of information the module provides, making it easy for users to understand the expected results.
662-669: Concise documentation for the Purchases Per Customer module.The Purchases Per Customer section provides a clear explanation of the module's purpose and benefits.
675-684: Straightforward example for the Purchases Per Customer module.The example code demonstrates proper usage of the PurchasesPerCustomer class with appropriate parameters.
690-705: Detailed documentation for the Days Between Purchases module.The Days Between Purchases section provides comprehensive information about the module's functionality and benefits, with clear applications for business use cases.
711-718: Clear example for the Days Between Purchases module.The example code effectively demonstrates how to use the DaysBetweenPurchases class.
724-728: Brief but informative documentation for the Transaction Churn module.The Transaction Churn section succinctly explains the module's purpose and key benefits.
734-743: Proper example for the Transaction Churn module with correct parameter name.The example code demonstrates the correct usage of the TransactionChurn class with the properly spelled
cumulativeparameter.
Added some docs examples and cleaned up some existing once to simplify/lint them.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation