Model creation for User User collanborative filtering

陌路散爱 提交于 2019-12-14 02:55:41

问题


I want to do a sort of user-user collaborative filtering wherein the users in the user-item matrix are a selected part of whole users in the database. These selected users are refreshed regularly with newly selected users preferences. New users shouldn't be added to the matrix. For a new user, based on his preferences we need to recommend items from the user-item matrix (which has only a part of users which are selected). I do not want to add the new anonymous users to the matrix.

Explored in Mahout, but need some help there. The Recommender Class in Mahout has recommend(...) method which takes the user_id as argument. This is not which I want. The method should accept the preferences and based on the model , items should be recommended. How to do it in Mahout?? Can we use PlusAnonymousUserDataModel ??

If not mahout, what other tools can accomplish this...

The code which I used with PlusAnonymousUserDataModel which is not giving any recommendations for the user who has recommendations with normal usage..

    DataModel model = new GenericBooleanPrefDataModel( GenericBooleanPrefDataModel.toDataMap( new FileDataModel(f)));
    TanimotoCoefficientSimilarity similarity = new TanimotoCoefficientSimilarity(model);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(1000, similarity, model);
    new_user_preferences = { ... } // new user items..
    DataModel plusmodel = new PlusAnonymousUserDataModel(model);
    PreferenceArray anonymousPrefs = new GenericUserPreferenceArray(new_user_preference.length);
    anonymousPrefs.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
    for(int i = 0;i < new_user_preference.length;i++)
    {
      anonymousPrefs.setItemID(i, new_user_preference[i]);
    }
    PlusAnonymousUserDataModel plusAnonymousModel = (PlusAnonymousUserDataModel) plusmodel;
    Recommender recommender1 = new GenericBooleanPrefUserBasedRecommender(model, neighborhood, similarity);
    plusAnonymousModel.setTempPrefs(anonymousPrefs);
    List<RecommendedItem> recommendations1 = recommender1.recommend(plusAnonymousModel.TEMP_USER_ID, 10);

Is there any problem with the code??


回答1:


sravan_kumar, if you replace model with plusAnonymousModel in 3 places:
TanimotoCoefficientSimilarity similarity = new TanimotoCoefficientSimilarity(plusAnonymousModel);
UserNeighborhood neighborhood = new NearestNUserNeighborhood(1000, similarity, plusAnonymousModel);
Recommender recommender1 = new GenericBooleanPrefUserBasedRecommender(plusAnonymousModel, neighborhood, similarity);

and initialize plusAnonymousModel right, just after initializing model:
PlusAnonymousUserDataModel plusAnonymousModel = new PlusAnonymousUserDataModel(model);
(there is no need in plusmodel variable, as you use it)
, you will get the desired results!

Also, change GenericUserPreferenceArray to BooleanUserPreferenceArray :)




回答2:


Yes, PlusAnonymousUserDataModel is the closest thing to what you want in Mahout. It's a bit of a band-aid, but works.



来源:https://stackoverflow.com/questions/9907320/model-creation-for-user-user-collanborative-filtering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!