Question

I have a list of items and their similarities from an ItemSimilarity job already. I want to now use that to get the recommendations for a specific user. The Java code i have right now does not work because i can't find the right way to pass the .txt file into an itemSimilarity. Here is the code i have so far:

class RecommenderIntro {

public static void main(String[] args) throws Exception {

DataModel model = new FileDataModel(new File("dataset/input/input.txt"));
DataModel itemSimilaritiesModel = new FileDataModel(new File("dataset/output/part-r-00000"));
ItemSimilarity itemSimilarity = new GenericItemSimilarity(itemSimilaritiesModel);
Recommender recommender = new GenericItemBasedRecommender(model, itemSimilarity);
Recommender cachingRecommender = new CachingRecommender(recommender);
List<RecommendedItem> recommendations = cachingRecommender.recommend(137413350, 10);
system.out.print(recommendations);

}

}

Just need to know how to recommend specific items to users using a pre-compiled .txt file of itemsimilarities

Thanks so much

Was it helpful?

Solution

Line #2 doesn't do anything that helps you. This creates a FileDataModel; you can't feed it stuff that's not user-item preferences, whereas I take it this is some textual representation of item-item similarities. It may not fail since both are CSV but the result is not at all item-item similarity.

What you want is FileItemSimilarity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top