mahoutmahout-recommender

display "movie name" instead of "movie id" as recommendation from apache mahout


I am developing a simple movie recommender system using apache mahout by referring a short video here- https://www.youtube.com/watch?v=yD40rVKUwPI. The code for recommender is

    public class App 
 {
    public static  List<RecommendedItem> getRecommend(int k) throws Exception
   {
            ClassLoader classLoader = App.class.getClassLoader();

            DataModel model = new FileDataModel(new    File(classLoader.getResource("data/dataset.csv").getFile()));
        UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
        UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model);
        UserBasedRecommender recommender = new     GenericUserBasedRecommender(model, neighborhood, similarity);
        List<RecommendedItem> recommendations = recommender.recommend(k, 3);
        return recommendations;
     }
}

enter image description here

This generates recommendations in the form of movie id's.What I want is to display names instead of movie id. The dataset I am using (which generates id's)has following columns in csv form

user_id   movie_id  rating

but since there is a MovieLens dataset which has two files- one with fields

   user_id   movie_id  rating

and second with

  movie_id   movie_name

How can i use the above resourcesto get movie_names instead of id. Is it possible with DataModel class or there is some other way out. I want recommendations as

movie_name  value

instead of present

movie_id  value

Solution

  • You likely cannot with Mahout alone. You will need to load the movie title CSV file using a CSV reader, or import it into a database, and map movie IDs back to names yourself.