2012年11月6日 星期二

[mahout]mahout recommender step


一般而言再使用mahout recommender來說,都有幾個步驟。

 

  1. 建立模型
  2. 計算相似度
  3. 找k-nearest neighbor 
  4. build recommender engine






public static void main (String args[])throws Exception{
DataModel model =new FileDataModel(new File("data/intro.csv"));
UserSimilarity similarity =new PearsonCorrelationSimilarity(model);
UserNeighborhood neighborhood =new NearestNUserNeighborhood(2,similarity,model);
Recommender recommender= new GenericUserBasedRecommender(model,neighborhood,similarity);
List recommendations =recommender.recommend(1, 2);
for(RecommendedItem recommendation :recommendations){
System.out.println(recommendation);
}

}

沒有留言:

張貼留言