If there's a website/app that sells products and my job is to determine the order/ranking in which the products should be displayed.

For example : I click on restaurants and a list of restaurants pops up, I have to determine in what order the restaurants should be displayed.

All the data like ratings, distance to the customer, profit to us, prices, CTR, total number of views etc is available.

But how should I approaching this problem of rankings them in an efficient order ? I have read about Learning to Rank and Collaborative Filtering but I am not sure if those are right for my problem, please help me out.



2 Answers 2


Collaborative Filtering would definitely be a good start. This would work as follows. For each user, you can fill in rankings for restaurants they have not yet ranked by averaging the ranks (or some other aggregation) of similar users who have rated that restaurant.

Alternatively, you could take a content based approach. Here, each restaurant has a collection of keywords, and using or rating a given restaurant updates a user's profile for those keywords. Then, the user's profile can be compared (via cosine similarity or something) to all other restaurants profiles. Then you order accordingly.

It may be more useful to map into a latent space first, but up to you.

  • $\begingroup$ What if I don't want to rank based on the individual customers but like just a universal ranking which could be efficient overall ? How can i approach that ? How exactly can i use all the data available to me generate an efficient ranking ? $\endgroup$ Commented Jun 28, 2018 at 13:13
  • $\begingroup$ So just one ranking of the restaurants that everyone sees? You could aggregate everyone's ratings to sort by highest rated restaurant, or rank my margin/profit on your end, etc. $\endgroup$
    – Andy M
    Commented Jun 29, 2018 at 13:43

If your goal is to generate one universal ranking for all users to see, rather than a ranking per user, then collaborative filtering will most likely be of little use.

There may be simpler ways than using machine learning to solve this problem.

Gathering data properly

Here is the trouble: the order in which you have been presenting the restaurants in the past has most likely biased your data. If restaurant A was always presented near the top of the list, and restaurant Z on the 10th page, then this could have an impact on variables like the CTR (maybe people get desperate around the 10th page and get less picky, giving Z a higher CTR and A a lower CTR!). Same with number of views (restaurants often on the first page will get more views) and ratings (the relationship here is less obvious, but I wouldn't be surprised if people who pick the first restaurant they see on the first page also happened to give better reviews, for example).

Ideally, you would run a proper experiment presenting the restaurants in a random order and gathering data from this experiment to create your ranking.

If you don't want to run a full-blown randomized experiment (which is understandable if this is a business), then you could keep the ranking the way it is, but sneak in a handful of restaurants selected at random onto the front page on every visit. This will allow you to gather data from the performance of the randomly presented restaurants while still offering a decent ranking to your customers.


You will need to determine what the criterion of success is. I will assume you are running some sort of website like JustEat where customers pick a restaurant and then order food. What you could do is score the restaurants according to the expected revenue from presenting them in the ranking. This would be something like:

  • The probability that a customer clicks on the restaurant if the restaurant is shown to them in the list
  • Multiplied by the probability that the customer buys from a restaurant after clicking on that restaurant
  • Multiplied by the cut you get from the average order from that restaurant

In essence, a restaurant would score high only if it can be expected that presenting that restaurant to the customer is likely to result in revenue.

Given this score, it would then make sense to order your restaurants in decreasing order of expected revenue.

  • $\begingroup$ good explanation! $\endgroup$ Commented Dec 30, 2018 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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