Item-based filtering

The ItemSimilarity attribute is the most important point to discuss here. Item-based recommenders are useful, as they can take advantage of something very fast; they base their computations on item similarity, not user similarity, and item similarity is relatively static. It can be precomputed, instead of recomputed in real time.

Thus, it's strongly recommended that you use GenericItemSimilarity with precomputed similarities, if you're going to use this class. You can use PearsonCorrelationSimilarity, too, which computes similarities in real time, but you will probably find this painfully slow for large amounts of data:

StringItemIdFileDataModel model = new StringItemIdFileDataModel( 
  new File("datasets/chap6/BX-Book-Ratings.csv"), ";"); 
 
ItemSimilarity itemSimilarity = new 
PearsonCorrelationSimilarity(model); ItemBasedRecommender recommender = new
GenericItemBasedRecommender(model, itemSimilarity); String itemISBN = "0395272238"; long itemID = model.readItemIDFromString(itemISBN); int noItems = 10; List<RecommendedItem> recommendations =
recommender.mostSimilarItems(itemID, noItems); System.out.println("Recommendations for item:
"+books.get(itemISBN)); System.out.println(" Most similar items:"); for (RecommendedItem item : recommendations) { itemISBN = model.getItemIDAsString(item.getItemID()); System.out.println("Item: " + books.get(itemISBN) + " | Item id:
" + itemISBN + " | Value: " + item.getValue()); } Recommendations for item: Close to the BoneMost similar items:Item: Private Screening | Item id: 0345311396 | Value: 1.0Item: Heartstone | Item id: 0553569783 | Value: 1.0Item: Clockers / Movie Tie In | Item id: 0380720817 | Value: 1.0Item: Rules of Prey | Item id: 0425121631 | Value: 1.0Item: The Next President | Item id: 0553576666 | Value: 1.0Item: Orchid Beach (Holly Barker Novels (Paperback)) | Item id: 0061013412 | Value: 1.0Item: Winter Prey | Item id: 0425141233 | Value: 1.0Item: Night Prey | Item id: 0425146413 | Value: 1.0Item: Presumed Innocent | Item id: 0446359866 | Value: 1.0Item: Dirty Work (Stone Barrington Novels (Paperback)) | Item id:
0451210158 | Value: 1.0

The resulting list returns a set of items that are similar to a particular item that we selected.

..................Content has been hidden....................

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