SlopeOneRecommender extends AbstractRecommender { @Override public float estimatePreference(long userID, long itemID) throws TasteException { DataModel model = getDataModel(); Float actualPref = model.getPreferenceValue(userID, itemID); if (actualPref != null) { return actualPref; } return doEstimatePreference(userID, itemID); } SlopeOneRecommender(DataModel dataModel);  SlopeOneRecommender(DataModel dataModel,
                             Weighting weighting,
                             Weighting stdDevWeighting,
                             DiffStorage diffStorage); @Override List<RecommendedItem> recommend(long userID, int howMany, IDRescorer rescorer); @Override float estimatePreference(long userID, long itemID); @Override void setPreference(long userID, long itemID, float value); @Override void removePreference(long userID, long itemID); @Override void refresh(Collection<Refreshable> alreadyRefreshed); @Override String toString();  }
@Test public void testEstimatePref() throws Exception { Recommender recommender = buildRecommender(); assertEquals(0.34803885284992736, recommender.estimatePreference(1, 2), EPSILON); }
@Test public void testDiffStdevBehavior() throws Exception { DataModel dataModel = getDataModel( new long[] {1, 2, 3}, new Double[][] { {0.1, 0.2}, {0.2, 0.3, 0.6}, {0.3, 0.3, 0.3}, }); Recommender recommender = new SlopeOneRecommender(dataModel); assertEquals(0.3257085f, recommender.estimatePreference(1, 2), EPSILON); }