# How do companies like Amazon track what products are most frequently bought together? [closed]

What methods could someone use to find out what products are most frequently grouped with each other per order? Are there applications that can make achieving this goal easier?

• What research have you done?
– Emre
Aug 6 '16 at 21:00

This is called Association Learning. Quoting Wikpedia:

Association rule learning is a method for discovering interesting relations between variables in large databases. It is intended to identify strong rules discovered in databases using some measures of interestingness

So, your question asks about how companies like Amazon and Walmart know what products are frequently bought together. So, that is done by the Apriori algorithm, which falls under the class of Association Learning algorithms.

Again, quoting Wikipedia:

Apriori is an algorithm for frequent item set mining and association rule learning over transactional databases. It proceeds by identifying the frequent individual items in the database and extending them to larger and larger item sets as long as those item sets appear sufficiently often in the database.

This algorithm generates rules which show what items are bought along with which items, depending on the support and confidence thresholds. (As you didn't ask about the particulars, I would skip the details. Pl check wikipedia for the finer details and the algorithm itself).

The arules package of R implements the apriori algorithm. Unfortunately, there is no fast implementation of the same in Python.

• An algorithm three orders of magnitude faster than Apriori is FP-growth. Don't know about R, but a fast Python 3 implementation is at least in Orange3-Associate package. Aug 7 '16 at 10:49
• @K3---rnc Yeah, FP-growth is pretty good. But, as the OP asked for a rough overview, I gave the simpler one as an example. You're free to add an answer with the FP-growth algo. though :)
– Dawny33
Aug 7 '16 at 14:52