The most basic user-based collaborative filtering can be implemented by initializing the previously described components, as follows:
First, load the data model:
StringItemIdFileDataModel model = new StringItemIdFileDataModel( new File("/datasets/chap6/BX-Book-Ratings.csv", ";");
Next, define how to calculate how the users are correlated; for example, using the Pearson correlation:
UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
Next, define how to tell which users are similar, that is, the users that are close to each other, according to their ratings:
UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model);
Now, we can initialize a GenericUserBasedRecommender default ...