top of page

Market Basket Analysis

Performed association rule mining to identify frequently bought item combinations.

Skills, Tech Stack, and Libraries

  1. Skills: Association Rule Mining, Data Wrangling, Statistical Analysis, Data Visualization

  2. Tech Stack: Python, SQL, Tableau, Power BI

  3. Libraries: Pandas, NumPy, Matplotlib, Seaborn, mlxtend


Description and Approach

Objective:

I conducted a market basket analysis to uncover associations between items frequently purchased together, helping businesses optimize cross-selling strategies and improve product placement.


Approach:
  1. Data Collection and Preprocessing:

    • Extracted transactional data from a retail database using SQL, where each record represented items purchased in a single transaction.

    • Cleaned and structured the data using Pandas, converting it into a transaction-item matrix required for association rule mining.

  2. Exploratory Data Analysis (EDA):

    • Analyzed item popularity and sales trends using Matplotlib and Seaborn.

    • Visualized the frequency of top-selling items and their contribution to overall sales.

  3. Association Rule Mining:

    • Applied the Apriori algorithm from the mlxtend library to identify frequent itemsets based on minimum support thresholds.

    • Generated association rules by calculating confidence and lift metrics to determine the strength of relationships between items.

  4. Insights and Recommendations:

    • Identified high-confidence rules (e.g., customers buying bread are also likely to buy butter) and grouped complementary products for cross-selling opportunities.

    • Recommended optimal shelf placements and bundling strategies to increase sales.


Dashboard Design:

Designed an interactive dashboard in Power BI to display:

  1. Frequently purchased itemsets and their associations.

  2. Heatmaps of confidence and lift scores for item pairs.

  3. Time-based analysis of item popularity for strategic seasonal planning.


Automation:

Automated the analysis pipeline to refresh the insights periodically as new transactional data became available.


Code Flow:

  1. Import transactional data into Pandas and preprocess it into a binary transaction-item matrix.

  2. Apply the Apriori algorithm using the mlxtend library to generate frequent itemsets.

  3. Extract association rules and calculate metrics like confidence and lift.

  4. Export processed data to Power BI for visualization and deployment.


Results

The market basket analysis provided actionable insights with the following outcomes:

  • Improved Cross-Selling Strategies: Identified item pairs frequently purchased together, leading to a 15% increase in cross-sales revenue.

  • Optimized Product Placement: Recommended adjustments to shelf arrangements, boosting customer convenience and sales.

  • Enhanced Customer Understanding: Gained insights into customer buying behavior, enabling tailored promotional campaigns.

  • Scalable Solution: The automated pipeline ensured continuous updates, keeping the analysis relevant with incoming data.


This project demonstrated the value of association rule mining in driving retail business strategies and maximizing sales potential.


Git Link

For more information and code, visit the Git link.

© 2020 by Satej Zunjarrao.

bottom of page