← All projects

Data MLxtend

Basket analysis for a British gift shop: data cleaning, RFM segmentation and association rules with Apriori.

  • Python
  • pandas
  • seaborn
  • MLxtend

View the GitHub repository

Context

Practical assignment of the BUT in Computer Science. From a year of transactions, the brief was to clean the data, describe buying behavior and surface products bought together.

Team and my role

Group project.

I took the lead on the project and handled the technical side.

Approach

  • Cleaning: removal of baskets with no identified customer, normalization of product names and exclusion of non-product lines such as postage or discounts.
  • Descriptive analysis: basket distribution by month, day and hour, basket size and best-selling items.
  • Customers: RFM segmentation into 6 segments, loyalty analysis and tracking of new and returning customers.
  • Association rules: Apriori over the last 30 days, with a minimum support of 2%, itemsets of size 3 at most and a minimum confidence of 80%, then sorted by lift.

Visuals

Facts and figures

valid after cleaning, from December 2010 to December 2011
18,044 baskets
and 3,835 distinct items
4,293 customers
of customers from the RFM analysis
6 segments
analyzed by Apriori, over the last 30 days
2,670 baskets
kept at 2% support and 80% confidence
6 rules
for the best rule, with 91.5% confidence
Lift of 29.44

What I took away

The main challenges and lessons came from managing the project and from setting up the initial requirements.