I have a list user data: user name, age, sex, address, location etc., and

a set of product data: Product name, Cost, description etc.

Now I would like to build a recommendation engine that will be able to:

1 Figure out similar products

eg :

name : category : cost : ingredients

x : x1 : 15 : xx1, xx2, xx3

y : y1 : 14 : yy1, yy2, yy3

z : x1 : 12 : xx1, xy1

here x and z are similar.

2 Recommend relevant products from the product list to a user

How can I implement this using mahout?

  • 1
    $\begingroup$ Do you have some other information about which user liked, rated or bought which product? $\endgroup$
    – Nitesh
    Commented Nov 19, 2014 at 10:09
  • 1
    $\begingroup$ no only user and product data $\endgroup$ Commented Nov 19, 2014 at 10:27
  • 2
    $\begingroup$ Clustering the products is easy enough (look up k-means or Gaussian mixture models), but recommending them will be difficult unless you can propose a model which relates them to the users. Since you have no training data for a supervised model you need to get it from somewhere; e.g., market research. Otherwise you can make up some heuristics yourself and use it to build a Bayesian prior, but I suspect this more complexity than you are comfortable with. Worry about mahout later; you need an algorithm, a model first. $\endgroup$
    – Emre
    Commented Nov 19, 2014 at 19:32
  • 1
    $\begingroup$ Without data associating the products and the customers, there is no way to build a list of recommended products on a per-user basis. It could be possible to group the items based on meta-data about the products - for example, each item would have a list of recommended items. This would be generated by products sharing tags, a price range, a brand name, or some other meta-data you have available. Do you have any additional meta-data? $\endgroup$ Commented Nov 19, 2014 at 20:33
  • $\begingroup$ Thanks for you reply @Emre,@ sheldonkreger. So how similar products can be found out? as product attributes i have name,category,cost and ingredients (some product may have 1 ingredients where as some other have 10..) I am new to recommendation system and I would like to know which are all the best algorithms and tools available to implement this problem.. $\endgroup$ Commented Nov 20, 2014 at 4:17

2 Answers 2


I recommend you to take a look to Oryx (https://github.com/OryxProject/oryx). Oryx is based on Apache Mahout (actually one of the creators of Mahout Sean Owen built it) and provides recommendation using collaborative filtering. Oryx is a very practical tool for implementing recommendation. I have used it in several projects: recommending products in retail stores (small businesses), building an e-commerce recommender and user similarity from mobile app interaction.

You just have to represent data in the form: UserId ItemId Value

Where value is a measure (subjective) of the importance or influence of the interaction between that user and the item. User and item can be anything actually, and the same procedure can be used for tagging. For example, for recommending songs, finding similar songs and bands, and finding similar users according to their music tastes you can represent data as

UserId SongId NumberOfPlays

Where NumberOfPlays is the amount of times a song has been played by user (in an online music service for example). This exampl was given in Myrrix the predecessor of Oryx. They also show how to recommend tags to questions in StackOverflow.

The github site is not that well documented but it will be enough to get it running (and working :))

  • $\begingroup$ In this case, you are suggesting the data to be fed something along the following lines, then? category_i, item_id_j, value_{i,j}. Here category_i denotes the i-th category and item_id_j denotes the j-th item and value_{i,j} denotes the value for the item category combination. For example, color can be one category and its value can be red for a given item. However, to feed it in, one would have to transform the dataset to read something like: color_red, item_i, 1 as one row and may be color_blue, item_i, 0 as another row. This way, we run into values that are both unary and numeric. $\endgroup$
    – Nitesh
    Commented Nov 24, 2014 at 19:41

Try using the item-based similarity algorithm available under Apache Mahout. It is easy to implement and you will have a good sense how the recommendation system for your data set will work. You could provide ingredients and category as the major inputs to get the similar products.As a neophyte to this field, I would say that this approach is an easy way for all the neophytes to get a good heads up of what kind of a result one can expect from building a recommendation system of their own.

  • $\begingroup$ Mahout does item based similarity. However, item based similarity in Mahout is calculated through users ratings of these items. In the dataset as described in the question, an item based similarity is not possible (at least in the framework used in Mahout's item-based similarity). $\endgroup$
    – Nitesh
    Commented Nov 21, 2014 at 22:51
  • $\begingroup$ I believe that in a proper case, the data should contain username, product name and rating to generate the recommendation system. Consider an overview of this scenario, you just need a couple of categorical & numerical variables. Can't we use category,product name and cost to replicate this case in here? It may not be a good way to do it but,do you think it is not possible to use item-based similarity here? $\endgroup$
    – SRS
    Commented Nov 24, 2014 at 14:44
  • $\begingroup$ Of course its possible to use the item categories/ features to create similarity. However, that representation will be sparse and might not yield meaningful similarities. Notice that when we have ratings, then for each item's vector, a component denotes a particular user's ratings. This inherently ensures that each user's rating is weighted equally when calculating similarity. In any case, one would have to do extensive preprocessing in order to get this dataset to be ready to be fed into Mahout. $\endgroup$
    – Nitesh
    Commented Nov 24, 2014 at 17:58
  • $\begingroup$ Thanks for your comments Nitesh Srinath. But it seams ( I am new to mahout and still experimenting) mahout is good at collaborative filtering. And what i need is something related to contend based filtering. I do not have any user ratings/preference value available. So is there any way to implement content based filtering in mahout or is there any other tools/libraries available.. $\endgroup$ Commented Nov 26, 2014 at 4:21

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.