1
$\begingroup$

I have a dataset of retail transactions wherein different users buy certain items together. For example, a user A buys a toothpaste, a toothbrush and a floss at the same time, and a user B buys a toothpaste, a shampoo and a soap together.

I'm required to find out for each item in the dataset a list of items that are frequently bought together with it. For instance, one may expect that whenever a toothbrush is purchased, a toothpaste can be one of the items that are frequently bought together with it.

I tried to make use of the Apriori Algorithm but that would only give me sets of items that are bought together or, I'm unaware if it can somehow be modified to predict frequent purchases for a list of items in the dataset.

Which other algorithm can I put to use here?

$\endgroup$
0
$\begingroup$

The simplest way is to build a matrix representing how often two items are bough together: $M[i,j]$ is the count of how many times items $i$ and $j$ are bought together (note that you need to fill only a diagonal matrix, since it's symmetric).

From there you can calculate whatever you need: most frequent $B$ item bought with a given item $A$, top most frequent pairs of items in general, etc.

You could also consider the matrix as a graph representation, and use algorithms specific to graphs.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.