Market Basket Analysis (Packaging)

A market basket analysis of product packaging using association rule-apriori algorithm written in R.

Photo by Mehrad Vosoughi on Unsplash


DQ Fashion is a fashion store that sells fashion items. Even though this store is quite developed, they have competitors and many products that are still in stock or slow-moving product. This project is about market basket analysis with the objective of creating innovative product packaging that can help to sell slow-moving items. Using the association rule package in R, this project tried to find the strongest relationship between each slow-moving item and the rest of the items.

After analyzing it, there are two product items which according to the manager still have a lot of stock and it is necessary to look for pairs of items for packaging. The two items of the product are “Tas Makeup” and “Baju Renang Pria Anak-anak”.


The manager wants to ask for a combination that can be bundled with the two slow-moving products.

Analytic Approach

Association analysis: build a model to find relationships of each item in dataset.

Data Requirements

Transactional data with 2 variables:

- Kode Transaksi

- Nama Barang

Exploratory Data Analysis

Statistic Top 10

Statistic Bottom 10

Data Preparation

Dataset is already in a format that is ready for processing.


This model requires a rule-based algorithm, we are going to use apriori algorithm from arules package in R.


In this model, there are 3 measurements, they are:

1. Support

Support is a formula that calculates the probability of a consumer buying a combination of items from the total number of transactions. The minimum support value (support threshold) is determined by the user.

2. Confidence

Confidence menghitung probabilitas kejadian suatu kombinasi item dibeli secara bersamaan, dimana salah satu item sudah pasti dibeli. Nilai confidence memiliki range dari 0–1, dimana confidence = 0 mengindikasikan bahwa item Y tidak pernah dibeli ketika item X dibeli, begitu juga sebaliknya.

3. Lift

Lift indicates that the relationship between items in a combination is valid, or whether a combination of items occurs together more often / less frequently than random.


Here's the result of this project:

Slow-moving item and the pairs

Tas Makeup

- {Baju Renang Anak Perempuan, Tas Pinggang Wanita} + {Tas Makeup}

- {Baju Renang Anak Perempuan, Tas Ransel Mini} + {Tas Makeup}

- {Baju Renang Anak Perempuan, Celana Pendek Green/Hijau} + {Tas Makeup}

Baju Renang Pria Anak-anak

- {Gembok Koper, Tas Waist Bag} + {Baju Renang Pria Anak-anak}

- {Flat Shoes Ballerina, Gembok Koper} + {Baju Renang Pria Anak-anak}

- {Celana Jeans Sobek Wanita, Jeans Jumbo} + {Baju Renang Pria Anak-anak}

Other projects: