Wednesday, 19 August 2015

Mahout: Preference data

Preference data is input to a recommender engine. Usually Preference data contains 3 things.
         1. User id
         2. Item id
         3. Rating (optional in some cases).
One Preference object represents, user’s preference for one item.

org.apache.mahout.cf.taste.model.Preference interface is used to represent a Preference Object. There are two implementations of Preference interface.
a.   GenericPreference
b.   BooleanPreference


a. GenericPreference
GenericPreference instance is constructed using userId, itemId and rating for this item.

Syntax
GenericPreference(long userID, long itemID, float value)

Example
GenericPreference prf = new GenericPreference("1,4,3");

b. BooleanPreference
BooleanPreference instance is constructed using userId, itemId. Rating for an item doesn’t matter here.

Syntax
BooleanPreference(long userID, long itemID)

Example
BooleanPreference pref = new BooleanPreference(1, 5)



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment