1
votes

I want to build a recommendation model based on Mahout. My dataset format has extra columns other than userID, itemID, rating and timestamp. Thus, I think I need to extend the FileDataModel.

I looked into JesterDataModel as an example. However, I have a problem with the logic flow. In its buildModel() method, an empty map "data" is first constructed. It is then thrown into processFile. I assume that "data" is modified in this method, since later it is used to construct the GenericDataModel However, data is a local variable instead of a class variable, so how is it modified?

processFile(iterator, data, timestamps, false);
return new GenericDataModel(GenericDataModel.toDataMap(data, true));
1
What do you want to do with this extra columns?Julian Ortega
@Julian For example, each user reads a book, rates it, and adds some tags. The extra columns are the tags. When recommend a book to a user, I would also like to see if the book's tags matches the user's. Of course I can create another data structure to store these tag preference, but ideally, I want to wrap up all the things into the DataModel.Jia

1 Answers

1
votes

I see... I believe you would have to rewrite major parts like DataModel, Similarities calculation, and so on and so on, to make that work. You can look at the Rescorer which allows you to introduce your own logic and filter items out or boost some other items based on your requirements.

In chapter 5 of the Mahout in Action book there is an example of how to use the Rescorer class. You can see the code here (link)