org.apache.mahout.cf.taste.eval.RecommenderBuilder Java Examples
The following examples show how to use
org.apache.mahout.cf.taste.eval.RecommenderBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericRecommenderBuilderTest.java From rival with Apache License 2.0 | 7 votes |
@Test public void testBuildDefaultRecommender() { RecommenderBuilder rb = new GenericRecommenderBuilder(); FastByIDMap<PreferenceArray> userData = new FastByIDMap<PreferenceArray>(); userData.put(1, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(1, 1, 1), new GenericPreference(1, 2, 1), new GenericPreference(1, 3, 1)))); userData.put(2, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(2, 1, 1), new GenericPreference(2, 2, 1), new GenericPreference(2, 4, 1)))); DataModel dm = new GenericDataModel(userData); Recommender rec = null; try { rec = rb.buildRecommender(dm); } catch (TasteException e) { e.printStackTrace(); } assertTrue(rec instanceof RandomRecommender); }
Example #2
Source File: BookRecommender.java From Machine-Learning-in-Java with MIT License | 5 votes |
public static void evaluateRecommender() throws Exception{ StringItemIdFileDataModel dataModel = loadFromFile("data/BX-Book-Ratings.csv",";"); RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator(); RecommenderBuilder builder = new BookRecommender(); double result = evaluator.evaluate(builder, null, dataModel, 0.9, 1.0); System.out.println(result); }
Example #3
Source File: MovieUserEvaluator.java From hiped2 with Apache License 2.0 | 5 votes |
public static void evaluate(String ratingsFile) throws TasteException, IOException { DataModel model = new FileDataModel(new File(ratingsFile)); RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator(); RecommenderBuilder recommenderBuilder = new MyRecommendBuilder(); evaluator.evaluate( recommenderBuilder, null, model, 0.95, 0.05 ); }