@@ -92,3 +92,60 @@ time_plot(
92
92
move_legend_outside = True ,
93
93
)
94
94
```
95
+
96
+ ## Analysis Modules
97
+
98
+ ### Product Association Rules
99
+
100
+ The product association module implements functionality for generating product association rules, a powerful technique
101
+ in retail analytics and market basket analysis.
102
+
103
+ Product association rules are used to uncover relationships between different products that customers tend to purchase
104
+ together. These rules provide valuable insights into consumer behavior and purchasing patterns, which can be leveraged
105
+ by retail businesses in various ways:
106
+
107
+ 1 . Cross-selling and upselling: By identifying products frequently bought together, retailers can make targeted product
108
+ recommendations to increase sales and average order value.
109
+
110
+ 2 . Store layout optimization: Understanding product associations helps in strategic product placement within stores,
111
+ potentially increasing impulse purchases and overall sales.
112
+
113
+ 3 . Inventory management: Knowing which products are often bought together aids in maintaining appropriate stock levels
114
+ and predicting demand.
115
+
116
+ 4 . Marketing and promotions: Association rules can guide the creation ofeffective bundle offers and promotional
117
+ campaigns.
118
+
119
+ 5 . Customer segmentation: Patterns in product associations can reveal distinct customer segments with specific
120
+ preferences.
121
+
122
+ 6 . New product development: Insights from association rules can inform decisions about new product lines or features.
123
+
124
+ The module uses metrics such as support, confidence, and uplift to quantifythe strength and significance of product
125
+ associations:
126
+
127
+ - Support: The frequency of items appearing together in transactions.
128
+ - Confidence: The likelihood of buying one product given the purchase of another.
129
+ - Uplift: The increase in purchase probability of one product when another is bought.
130
+
131
+ Example:
132
+
133
+ ``` python
134
+ from pyretailscience.product_association import ProductAssociation
135
+
136
+ pa = ProductAssociation(
137
+ df,
138
+ value_col = " product_name" ,
139
+ group_col = " transaction_id" ,
140
+ )
141
+ pa.df.head()
142
+ ```
143
+ <!-- markdownlint-disable MD013 -->
144
+ | product_name_1 | product_name_2 | occurrences_1 | occurrences_2 | cooccurrences | support | confidence | uplift |
145
+ | :-----------------| :-----------------------------| ---------------:| ---------------:| ---------------:| ---------:| -----------:| -------:|
146
+ | 100 Animals Book | 100% Organic Cold-Pressed... | 78 | 78 | 1 | 0.000039 | 0.0128205 | 4.18 |
147
+ | 100 Animals Book | 20K Sousaphone | 78 | 81 | 3 | 0.000117 | 0.0384615 | 12.10 |
148
+ | 100 Animals Book | 360 Sport 2.0 Boxer Briefs | 78 | 79 | 1 | 0.000039 | 0.0128205 | 4.13 |
149
+ | 100 Animals Book | 4-Series 4K UHD | 78 | 82 | 1 | 0.000039 | 0.0128205 | 3.98 |
150
+ | 100 Animals Book | 700S Eterna Trumpet | 78 | 71 | 1 | 0.000039 | 0.0128205 | 4.60 |
151
+ <!-- markdownlint-enable MD013 -->
0 commit comments