I have the following dataset where each row represents a customer, and each column is a product. So for example, the first customer (row 0) buys product 2 and product 7. The second customer (row 1) buys products 3,6 and 7. And so on...

Basically I want to recommend customers who are already buying certain products, some other products. Here is an example:

Let's say I choose all customers who are buying products 1 and 4. How would I recommend them the next best...let's say 3... products based on what other 1 and 4 customers are buying?

I'd like to use keras neural networks or random forests for this kind of task. Thanks :)

product 1.......product 2.........product 3....... product 4...... product 5........ product 6..... product 7

enter image description here


1 Answer 1


This is a classic case of recommendation problem. There are a couple of steps in which a recommendation is made:

  1. Candidate Generation - What to show to a customer?
  2. Candidate Ranking - How to show the items to the customer?
  3. Personalisation - How to show the items to each customer?

Step 1 and 2 are general that means they talk about the overall trend and customer base, meaning we perform these steps by saying in general what would happen.

Step 3 is more personalised, where the ranking (order) in which the items are shown can be different for different customers.

For starters you should experiment with Singular Value Decomposition and Matrix Factorisation for recommendation.

If you have already tried your hand at these, then you should go with word2vec or doc2vec for building the step 1 and 2 and some kind of neural network at the end that ties to it in the end.

  • $\begingroup$ Thanks Kaustubh. At this stage, I actually just want to get a single output, like people buying products 1 and 2 -> probabilities that they will buy 3,4,5,6,7, and then say, recommend them the highest 3 probabilities. $\endgroup$
    – Programmer
    Jul 3, 2018 at 4:24

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