Created
October 5, 2010 14:38
-
-
Save anonymous/611661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ItemBasedRecommender { | |
public static void main(String[] args) throws Exception { | |
DataModel model = new FileDataModel(new File("model.csv")); | |
RecommenderBuilder recommenderBuilder = new RecommenderBuilder() { | |
public Recommender buildRecommender(DataModel model) throws TasteException { | |
ItemSimilarity similarity = new EuclideanDistanceSimilarity(model); | |
return new GenericItemBasedRecommender(model, similarity); | |
} | |
}; | |
Recommender recommender = recommenderBuilder.buildRecommender(model); | |
List<RecommendedItem> recomendations = recommender.recommend(1, 5); | |
for (RecommendedItem recommendedItem : recomendations) { | |
System.out.println(recommendedItem); | |
} | |
RecommenderIRStatsEvaluator statsEvaluator = new GenericRecommenderIRStatsEvaluator(); | |
IRStatistics stats = statsEvaluator.evaluate(recommenderBuilder, null, model, null, 2, GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0); | |
System.out.println(stats.getPrecision()); | |
System.out.println(stats.getRecall()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment