Through data mining, stores make the most out of their customers’ data. An analytic approach called Market Basket Analysis in Data Mining reveals items customers purchased together or are likely to purchase together. By predicting customers’ purchase behaviors, market basket analysis in data mining helps retailers better understand and ultimately serve their customers.

This tutorial will explain how market basket analysis in data mining works and how to calculate the metrics. 

What is Market Basket Analysis?

In this digital age, online shopping has grown highly popular among people, and it is difficult to find someone who has not been exposed to it. Because of the rapid growth of online shopping platforms, almost anything, from food to automobiles to housing, can now be found and purchased online.

Also, as digital marketing and analytics continue to develop in tandem, upselling and cross-selling have become the word of the decade. Let’s look at a basic situation in your local grocery store to help you understand what we’re talking about. If a store notices an increase in bread sales, they can further upsell by lowering the price of butter and jam, causing more customers to buy them together. 

This is because the shop knows from experience that most customers who buy bread also buy butter or jam. So, when it comes to gaining customer insights, market basket analysis in data mining remains a key factor. As a result, market basket analysis in data mining is a technique for identifying useful and important methods of frequently purchased products in a store’s transaction history.

Market basket analysis (MBA) is a data mining technique for identifying purchase patterns in any retail environment. MBA is a set of statistical affinity calculations that highlight purchasing patterns to help business leaders better understand – and ultimately serve – their customers. MBA, in its most basic form, searches for the most common product combinations in transactions.

Simply put, MBA is a data mining technique that allows a store owner to analyze and determine product combinations, which items are related, and which items customers frequently purchase together. It’s a lovely strategy based on the basic principle that if we buy something, we’re obligated to buy or avoid something else (or a bunch of things).

Market basket analysis in data mining is a method of identifying connections between entities and objects that frequently appear together, such as the contents of a shopper’s cart. Market basket analysis in data mining examines collections of items to identify affinities that are relevant within the different contexts of customer touchpoints for the purposes of customer-centricity. Following are some examples:

  • Product placement: Finding products that are frequently purchased together and strategically placing them near each other to encourage customers to buy both. This placement can be physical, such as product placement on shelves in a physical store, or virtual, such as in a print catalog or on an e-commerce site.
  • Point-of-Sale: Companies may use the affinity grouping of multiple products as evidence that customers are likely to buy certain sets of products at the same time. When certain products are bundled together, this allows for cross-selling or suggests that customers might be willing to buy more.
  • Customer Retention: When customers contact a company to end a relationship, a representative from the company may use market basket analysis in data mining to determine the best incentives to offer in order to keep the customer’s business.

MBA can be used to suggest a purchase based on the lack of a common pairing, such as when a customer orders only a small sandwich at a fast-food restaurant. They may be more likely than someone who purchased a large sandwich to purchase a dessert or a second sandwich.

Replicate Data in Minutes Using Hevo’s No-Code Data Pipeline

Hevo Data, a Fully-managed Data Aggregation solution, can help you automate, simplify & enrich your aggregation process in a few clicks. With Hevo’s wide variety of connectors and blazing-fast Data Pipelines, you can extract & aggregate data from 150+ Data Sources (including 40+ Free Sources) straight into your Data Warehouse, Database, or any destination. 


Hevo is the fastest, easiest, and most reliable data replication platform that will save your engineering bandwidth and time multifold. Try our 14-day full access free trial today to experience an entirely automated hassle-free Data Replication!

Purpose of Market Basket Analysis

The essential purpose of market basket analysis exists to determine which products people desire to buy. Sales and marketing teams can use market basket analysis to create more successful product placement, cross-sell, pricing, and up-sell strategies.

Purpose of Market Basket Analysis
Image source

Customer Satisfaction and Sales can both benefit from market basket analysis. Retailers can use data to determine which products are frequently purchased together and then optimize product placement, offer special deals, and create new product bundles to encourage more sales of these combinations.

These enhancements can increase sales for the retailer while also making the customer’s shopping experience more productive and valuable. Customers may feel a stronger sentiment or brand loyalty toward the company if market basket analysis in data mining is used.

Large volumes of transactional data are typically required to generate reliable insights from MBA. Without highly scalable storage and compute resources, processing large data sets is difficult. Modern cloud-based architectures enable more agile data mining and analytics, allowing you to test a variety of customer behavior theories or assess the success of a recent marketing campaign.

How Does Market Basket Analysis in Data Mining Work?

Market basket analysis in data mining is modeled on the association rule mining. Association rule mining is a type of machine learning that teaches you how to account for products you bought together.

Therefore, association rule mining is a rule-based machine learning method for discovering meaningful correlations between items based on their co-occurrence in a data set. It is also a method used to uncover relationships between variables in huge databases and forecast the likelihood of products being purchased together. 

rule-based machine learning
Image Source

Also, association rules count the number of times items appear together, looking for associations that happen considerably more frequently than expected. The equation of the association mining rule for market basket analysis in data mining remains the IF {}, THEN {} construct.

market basket analysis if and then
Image source
  • IF means Antecedent: Antecedents are the items found within the data or in the basket initially intended and picked up by the customer owing to their needs.
  • THEN means Consequent: Consequents are the items that are frequently found in the same basket as an antecedent or a group of antecedents.

Retailers will be able to predict customer behavior patterns using these technologies. These will help them design various combinations with offers based on this, and customers will be more likely to buy such products. This analysis enhances the company’s sales and revenue.

What Makes Hevo’s ETL Process Best-In-Class

Providing a high-quality ETL solution can be a difficult task if you have a large volume of data. Hevo’s Automated, No-Code Platform empowers you with everything you need to have for a smooth data replication experience.

Check out what makes Hevo amazing:

  • Fully Managed: Hevo requires no management and maintenance as it is a fully automated platform.
  • Data Transformation: Hevo provides a simple interface to perfect, modify, and enrich the data you want to transfer.
  • Faster Insight Generation: Hevo offers near real-time data replication so you have access to real-time insight generation and faster decision making. 
  • Schema Management: Hevo can automatically detect the schema of the incoming data and map it to the destination schema.
  • Scalable Infrastructure: Hevo has in-built integrations for 150+ Data Sources (with 40+ free sources) that can help you scale your data infrastructure as required.
  • Live Support: Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.

Algorithms Used in Market Basket Analysis

Market Basket Analysis employs a variety of techniques and algorithms. One of the most important goals is to “predict the likelihood of customers purchasing items together.

  •  Apriori Algorithm: The Apriori Algorithm is a popular market basket analysis algorithm that uses the Association Rule algorithm. It is also thought to be more precise than the AIS and SETM algorithms. It aids in the discovery of common transaction itemsets and the identification of association rules between them. The Apriori Algorithm’s drawback is the frequent generation of itemsets. Because of the large database, it must scan the database multiple times, which adds time and reduces performance. It employs the ideas of assurance and support.
  • AIS Algorithm: On the entire database or transactional data, the AIS algorithm creates multiple passes. It scans all transactions during each pass. As you can see, it counts the support of individual items in the first pass and then determines which of them are frequent in the database. To generate candidate itemsets, large itemsets from each pass are enlarged. The common itemsets between these itemsets of the previous pass and then items of this transaction are determined after each scanning of a transaction.
  • SETM Algorithm: The AIS algorithm is very similar to this one. The SETM algorithm performs collective database passes. As you can see, it counts the support for single items in the first pass before determining which of them are frequent in the database. The candidate itemsets are then generated by enlarging large itemsets from the previous pass. In addition, the SETM algorithm associates the generating transactions’ TIDs (transaction ids) with the candidate itemsets.
  • FP Growth: FP Growth is known as the Frequent Pattern Growth Algorithm. The FP growth algorithm is based on the idea of representing data as an FP tree or Frequent Pattern. FP Growth is thus a technique for mining frequent itemsets. This algorithm is an advancement to the Apriori Algorithm. The frequent pattern can be generated without using candidate generation. The association between the itemsets is maintained by this frequent pattern tree structure.

Types of Market Basket Analysis in Data Mining

There are three types of market basket analysis in data mining:

Types of Market Basket Analysis in Data Mining
Image source

Descriptive Market Basket Analysis 

This approach of Market Basket Analysis in Data Mining, which is the most popular, derives its conclusions from previous data. The analysis does not make any predictions but, instead, uses statistical approaches to rate the relationship between items. It uses the unsupervised data mining model. 

Predictive Market Basket Analysis

This Market Basket analysis in Data Mining uses supervised data mining models such as classification and regression. Its primary purpose is to imitate the market to figure out what causes things to happen. Essentially, to calculate cross-selling, it takes into account items purchased in a specific order. 

Differential Market Basket Analysis

This type of market basket analysis in data mining helps analyze competitors. It compares purchase histories between stores, seasons, periods, days of the week, and other variables to uncover fascinating patterns in consumer behavior. 

Metrics for Market Basket Analysis in Data Mining

The different metrics for Market Basket Analysis in Data Mining are discussed here. To your association rules, you can apply a variety of interesting measures. These include:

Think about this scenario: A popular e-commerce website processed 4000 transactions. They want to figure out how much support, confidence, and lift there is for the two items, a phone, and a phone case, out of 5000 transactions. There are 500 transactions for the phone, 800 transactions for the phone case, and 1000 transactions for both.


  • Support will be able to tell us how frequently this particular combination of items was purchased. The percentage of your transactions that contain an association rule is the easiest metric to calculate. It also refers to the percentage of transactions that includes both A and B. Support informs us how frequently an item or a group of items is purchased.
  • To calculate, divide the number of transactions that include A by the total number of transactions.

Support = freq (A, B)/N

support(phone) = transactions related to phone/total transactions

i.e. support -> 500/4000=12.5%

Do the same calculation for B. This allows us to recognize the frequency of item sets and filter out the less common ones.


  • With confidence, you can be more specific in your evaluation of this association rule. Confidence provides us with the likelihood of the “consequents” following the “antecedents.” It also tells us how often A and B are purchased together for the number of times A is purchased.
  • Therefore, confidence is calculated with combined/individual transactions.

Confidence = freq (A, B)/ freq(A)

Confidence = combined transactions/individual transactions

i.e. confidence -> 1000/500=20%

As you can see, this metric provides us with a unique and potentially more valuable insight into the nature of client behavior; we get not only frequency but also a measure of likelihood.


  • It represents the power of an association rule over the occurrence of A and B at random. The lift is calculated to determine the sales ratio.
  • Lift = support (A, B) percent/ support (A) percent x support (B) percent

Lift -> (500) / 12.5 x 20 = 2

When the Lift value is less than 1, buyers are less likely to purchase the combination.

Benefits of Market Basket Analysis in Data Mining

Implementing market basket analysis in data mining has numerous benefits. It helps retailers and companies to:

  • Increase Customer Engagement.
  • Improve Customer Experience.
  • Boost Sales and increase ROI.
  • Help to understand customers better.
  • Optimize Marketing Strategies and Campaigns.
  • Identify Customer Behavior and Pattern.
  • Customize Promotions.
  • Identify Sales Influencers.
  • Arrange Stock-keeping Unit (SKU) Display.
  • Help in setting prices.
  • Maintain Inventory.
  • Improve Storefront Assortment.
  • Target Marketing.
  • Product Recommendation.

Market basket analysis in Data Mining remains a viable option for insights into both the brick-and-mortar stores and e-commerce industries.


This article looked at market basket analysis in data mining and calculated the measures of association rules. Just as you’ve read, market basket analysis helps companies and retailers to evaluate their buying behavior and foretell their succeeding purchases. If used efficiently, it can considerably increase cross-selling and raise your customer’s lifetime value.

visit our website to explore hevo

Hevo Data, a No-code Data Pipeline provides you with a consistent and reliable solution to manage data transfer between a variety of sources and a wide variety of Desired Destinations, with a few clicks. Hevo Data with its strong integration with 150+ data sources (including 40+ free sources) allows you to not only export data from your desired data sources & load it to the destination of your choice, but also transform & enrich your data to make it analysis-ready so that you can focus on your key business needs and perform insightful analysis using BI tools.

Want to take Hevo for a spin? 

Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

Isola Saheed Ganiyu
Technical Content Writer, Hevo Data

Isola is a freelance writer specializing in the domains of data integration and data analysis. He has a passion towards creating engaging and educational content, breaking down these sophisticated subjects for easily understanding.

No-code Data Pipeline For Your Data Warehouse