Exploring the user-based recommender 1

recommending items to some user, denoted by u, as seen below



 

It would be terribly slow to examine every item. In reality, a neighborhood of most similar users is computed first, and only items known to those users are considered:


Exploring the user-based recommender 1_第1张图片
 

 The basic flow to build a CF likes blow codes in mahout:

DataModel model = new FileDataModel(new File("intro.csv"));
UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, model);

Recommender recommender = new GenericUserBasedRecommender( model, neighborhood, similarity);

//retrive recommend result for user 1 
List<RecommendedItem> recommendations =  recommender.recommend(1, 1);

 

 The content of intro.csv file is formatted by fields UserID  ItemID  PreferenceValue

4,103,3.0
4,104,4.5
4,106,4.0
5,101,4.0
5,102,3.0
5,103,2.0
5,104,4.0
5,105,3.5

 

 

 

 Exploring user neighborhoods

  • Fixed-size neighborhoods

 UserNeighborhood neighborhood = new NearestNUserNeighborhood(100, similarity, model);


Exploring the user-based recommender 1_第2张图片

  •  Threshold-based neighborhood

 UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.7, similarity, model);
 
Exploring the user-based recommender 1_第3张图片
 

 

 

 

你可能感兴趣的:(user)