Online learning engine

In any online platform, the new users will continue increasing. The previously discussed approach works well for the existing user. It is expensive to create a recommendation instance for every new user that's added. We cannot ignore the users that have been added to the system after the recommendation engine is made. To cope with situations that are similar to this, Apache Mahout has the ability of adding a temporary user to a data model.
The general setup is as follows:

  • Periodically recreate the whole recommendation using current data (for example, each day or hour, depending on how long it takes)
  • Always check whether the user exists in the system before going for a recommendation
  • If the user exists, then complete the recommendations
  • If the user does not exist, create a temporary user, fill in the preferences, and do the recommendation

The first step seems to be tricky, in regards to how frequently the whole recommendation is to be generated using the current data. If the system is huge, memory constraints will be there, because when the new recommender is being generated, the old, working recommender should be held in memory, so the request is being served from the old copy until the new recommender is ready.

As for the temporary users, we can wrap our data model with a PlusAnonymousConcurrentUserDataModel instance. This class allows us to obtain a temporary user ID; the ID must later be released so that it can be reused (there's a limited number of such IDs). After obtaining the ID, we have to fill in the preferences, and then we can proceed with the recommendation, as always:

class OnlineRecommendation{ 
 
  Recommender recommender; 
  int concurrentUsers = 100; 
  int noItems = 10; 
 
  public OnlineRecommendation() throws IOException { 
     
     
    DataModel model = new StringItemIdFileDataModel( 
      new File /chap6/BX-Book-Ratings.csv"), ";"); 
    PlusAnonymousConcurrentUserDataModel plusModel = new 
PlusAnonymousConcurrentUserDataModel
(model, concurrentUsers); recommender = ...; } public List<RecommendedItem> recommend(long userId,
PreferenceArray preferences){ if(userExistsInDataModel(userId)){ return recommender.recommend(userId, noItems); } else{ PlusAnonymousConcurrentUserDataModel plusModel = (PlusAnonymousConcurrentUserDataModel)
recommender.getDataModel(); // Take an available anonymous user form the poll Long anonymousUserID = plusModel.takeAvailableUser(); // Set temporary preferences PreferenceArray tempPrefs = preferences; tempPrefs.setUserID(0, anonymousUserID); tempPrefs.setItemID(0, itemID); plusModel.setTempPrefs(tempPrefs, anonymousUserID); List<RecommendedItem> results =
recommender.recommend(anonymousUserID, noItems); // Release the user back to the poll plusModel.releaseUser(anonymousUserID); return results; } } }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.254.90