package com.stelmod.recommendations;

import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.recommender.Recommender;
import org.apache.mahout.cf.taste.similarity.UserSimilarity;

import java.io.File;
import java.net.URL;
import java.util.List;

public class UserPredictions {

    public static void main(String[] args) throws Exception {
        URL inputStream = Thread.currentThread().getContextClassLoader().getResource("ml-small.csv");

        File inputFile = new File(inputStream.toURI());
        DataModel dataModel = new FileDataModel(inputFile);

        UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
        RecommenderBuilder recommenderBuilder = new NN_Pearson_GenericRecommender(20, similarity);
        Recommender recommender = recommenderBuilder.buildRecommender(dataModel);
        List<RecommendedItem> recommendedItems = recommender.recommend(285, 10);
        recommendedItems.forEach(item -> System.out.println(item));
    }
}

@@ -568,16 +568,172 @@
 ions %7B%0A%0A
+    public static final int USER_ID = 285;%0A    public static final int NUMBER_OF_RECOMMENDATIONS = 10;%0A    public static final int NEIGHBORHOOD_SIZE = 20;%0A%0A
     publ
@@ -1169,18 +1169,33 @@
 mmender(
-20
+NEIGHBORHOOD_SIZE
 , simila
@@ -1275,32 +1275,33 @@
 der(dataModel);%0A
+%0A
         List%3CRec
@@ -1359,15 +1359,42 @@
 end(
-285, 10
+USER_ID, NUMBER_OF_RECOMMENDATIONS
 );%0A 

Extract a few constants