Home » Uncategorized

Maximizing Sales with Market Basket Analysis

Sales data analyses can provide a wealth of insights for any business but rarely is it made available to the public. In 2018, however, a retail chain provided Black Friday sales data on Kaggle as part of a Kaggle competition. Although the store and product lines are anonymized, the dataset presents a great learning opportunity to find business insights! In this post, we’ll cover how to prepare data, perform basic analysis, and glean additional insights via a technique called Market Basket Analysis.

Let’s see what the data looks like. We use Pivot Billions to analyze and manipulate large amounts of data via an intuitive and familiar spreadsheet style. After importing, we see that the data contains over 500K rows at the bottom, along with example data for each column.

E-6jA-CWjDOwLKIV1PlC4HNBMx0HJGSTTDcBgdXNtOSvpVcsZHEhyvMDnbuFZH5HnzXCmLLyfHoDvAW0rRv2A4FE25MKRnCsOyRICCiV7Q4G88mF9WkVdPSJey52p2Lly4EhgpbM

Visualizing the distribution of each column is easy with a simple click of the column name. Overall the data is clean, but Product_Category_2 and Product_Category_3 has many missing values (NAs). They seem like subcategories of Product_Category_1 which has no missing values. Therefore, let’s ignore them for now.

Uqr04AQTnj9Ao7e0en2_zxEqYz57WT2wNqJgWARAoBw-GRJuyH8yOZt2seXuXzNYhhmuJYQrF-HiaW4mXOV_m_iKunjQe2PU5YqR2aXJAfjgUUYzHq6JDMANIVloZeFhjzEREtv5

Our next step is preparing data for analysis. First, “Purchase” needs to be divided by 100 to show cents as a decimal point. We define a float column called Total_Purchase and set ToF(Purchase)/100.

Second, let’s make a column combining gender with age to visualize a bar plot. We define a string column called Gender_Age and then set Gender + Age as the below screenshot.

05yL0DjJfZ1tns5VYicNsy67J0a1993tYswJGTM6Uvzrj2I72EOATfb3yOLz9lfMCBTCHNnjtexB4ya2kFZysHUkHk6mQqdAyUPvC73UAXhLQxt5hZ_lMHaMoRu7ywk4J1NHy3-7

Chig9O1kpCAJdfn1AijklOrEcftgga2TXG_PyRFD1V3guwzHy92cUZrPPQD2pySXt8BoC6Ur6rvPsa0PiB-v0yq0snYRoGfaEcXq5qie_yazKTtQJQADnmdfpaxmdowxrKH6DJ7n

In Pivot Billions, we can pivot data like Excel. It helps to easily find out the demographics of customers, sales per city, occupation, product category and so on. The bar chart below shows total purchases by product category.

aSw4CrrezbKJD7-TESN5lgLRpNgKDop9pS7qNpSmjZXTOeVa4VITLUR8j4Pb1ie1Kq3udD-5ruyTg1WJ7Hf8okI2YKXTUydw2fXZQmG4iAwmtcdiDPPmiXf1jZ3ocj5UYY9f8cSe

We see that product category 1 is the most popular. It turns out that it generates about 40% of total purchases in this retail chain, and combined purchases from categories 1, 5, and 8 account for more than 70%.

Next, let’s examine the data a little more closely! The bar chart below shows total purchases and customer demographics by city.

ZpQ0Lu3mOw2IoPF7jnqb3Q6YwWnsnZ5rYmZ7_iJK-VLaAHgKHKWS0G4EMTj6CG7f8YO730WoR0YSf6cAHM25wB6Ms5jLSzFLbA_XGdjyxgPeOqk0SC8O0Njxlok24lq-pogLpZg9

City B has the most sales, and the majority of customers are males ranging in age from the 20’s to 30’s in each city. But City A has a lower ratio of total purchases from customers over 35 compared to the other two cities. City A may have an untapped opportunity to target older demographics in their area. We don’t know each city’s demographics since they’re not revealed in this dataset, but it needs to be considered to understand what causes the differences as a realistic next step. It gives us solid insight for discussing with marketing teams.

Lastly, let’s do Market Basket Analysis which uses association rule mining on transaction data to discover interesting associations between the products! I’m going to use Apriori algorithm in Python. R also has Apriori algorithm. For further information, please check out the following articles: Apriori(Python), Apriori(R)

h_YGTZISlEBWtzcVVxq-rXQZ6wMrSOd8dY0V7sLOL7xtNR1aTbzAaoIGPDJKVUs33w2nWPyeUzvl6_YD9Cyi7BHtbhVajjoib_ed9fCAh4M9JoOgYfzmHSWDvTQP-ZqJXPoaA7kJ

pZyo7xlgdUku4dRjXF-0pYgOWzMx2Vs77bGHbp73abeLhM-0tdhNNcAQLJtb-3eFgOp5cnFBHsvvvLjsF-tzFEDsFrBERd4vs3vUQOSvHRd5fM5TiE3_hrhdMn-1EGpKognPM44k

We’ll explain briefly what the metrics indicate.

  • Support represents how frequently the items appear in the data.
  • Confidence represents how frequently the if(antecedents)-then(consequences) statements are found to be true.
  • Lift represents how much larger or smaller confidence than expected confidence is. If a lift is larger than 1.0, it implies that the relationship between the items is more significant than expected.The larger lift means more significant association.

Here’s the result of top 20 lift values by ascending.

N02a6TxnVma9LLbHHbXAdbIN4UCAL3BJOWpq_cbXc-W0AJlJ8-ODGvnZDTd2nBkGiqiHg1_l0n00FAWoXswu3DOthFdQkwLt2T_CVWUra8gH_OkGWhw7Nc0bBdGSLROF3rV5mcbW

In the Market Basket Analysis, we found strong cross-product purchasing patterns between certain products! These results can be the basis for further analysis or discussion if we are able to know more about the retail chain, and can lead to opportunities for strategic pricing and promotions.

Leave a Reply

Your email address will not be published. Required fields are marked *