I am looking for a statistical model to detect grouping patterns among a population X of n element with respect to their association with k elements of population Y. In modern marketing, an example of that would be "customers who bought X also bought Y", such as on Amazon etc.

X (person)  Y (purchase)
Jimmy       Lure
Joe         Fishing Rod
Jimmy       Fishing Rod
Sue         Sewing Machine
Sue         Thread
Patty       Sewing Machine
Jack        Tennis Balls

Above is just a very simple example. But imagine that 80% of people who bought a Fishing Rod also bought Lure and similar for Sewing Machine vs Thread. While the pattern may be obvious to the naked eye, I am looking for a more deterministic algorithm to detect this seemingly simple pattern. Imagine that this is a simple two dimensional array. Could you produce a pseudo code (or Java, Python, C or whatever suits you) algorithm that I could use to determine the most closely related elements in X based on their association with elements from Y?


The apriori algorithm is a classic algorithm and looks like a match for what you want to. This type of problem is known as association rule learning. There is an open source data mining toolkit called weka that has implementations of the apriori algorithm, and is very easy to use.

Weka: http://www.cs.waikato.ac.nz/ml/weka/

Apriori: http://en.wikipedia.org/wiki/Apriori_algorithm


Just to complement the answer from PeterRabbit, if you are using R you might want to know that the Apriori algorithm is available via the package arules.


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.