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"), ...

Get Machine Learning in Java - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.