Mahout custom data

46 Views Asked by At

I need to make a recommendation system using mahout. My data has the following data pieces:

  • userID -> The numerical id of the user
  • foodID -> Contains the numerical id of the food (for example ketchup's id is 88)
  • rating -> Rating the user gave the item from 1 to 5
  • brandID -> The numerical id of the foodID brand (for example Heinz may be id 4)

Using the code below:

 UserBasedRecommender recommender;
        int userId = 5;

        try {
            File file = new File(getClass().getResource("databaseFILE.csv").getFile());
            DataModel dataModel = new FileDataModel(file);

            UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(dataModel);
            UserNeighborhood userNeighborhood = new ThresholdUserNeighborhood(0.1, userSimilarity, dataModel);
            recommender = new GenericUserBasedRecommender(dataModel, userNeighborhood, userSimilarity);

            List<RecommendedItem> recommendations = recommender.recommend(userId, 5);
            for (RecommendedItem recommendation : recommendations) {
                System.out.println(recommendation);
            }


        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        } catch (TasteException e) {
            throw new RuntimeException(e.getMessage(), e);
        }

This gives an output for the itemID and its corresponding value, however I get no result for the brandID. Im not sure how I would change this so that the brandID can also be included within the data structure.

Thanks for any help :)

0

There are 0 best solutions below