@Test public void testNoSimilarity() throws Exception { DataModel dataModel = getDataModel( new long[] {1, 2, 3, 4}, new Double[][] { {1.0, null, 1.0, 1.0}, {1.0, null, 1.0, 1.0}, {null, 1.0, 1.0, 1.0}, {null, 1.0, 1.0, 1.0}, }); LogLikelihoodSimilarity similarity = new LogLikelihoodSimilarity(dataModel); assertCorrelationEquals(Double.NaN, similarity.itemSimilarity(1, 0)); assertCorrelationEquals(Double.NaN, similarity.itemSimilarity(0, 1)); assertCorrelationEquals(0.0, similarity.itemSimilarity(2, 3)); assertCorrelationEquals(0.0, similarity.itemSimilarity(3, 2)); }
@Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { DataModel dataModel = getDataModel(); long preferring1 = dataModel.getNumUsersWithPreferenceFor(itemID1); long numUsers = dataModel.getNumUsers(); return doItemSimilarity(itemID1, itemID2, preferring1, numUsers); }
LogLikelihoodSimilarity extends AbstractItemSimilarity implements UserSimilarity { @Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { DataModel dataModel = getDataModel(); long preferring1 = dataModel.getNumUsersWithPreferenceFor(itemID1); long numUsers = dataModel.getNumUsers(); return doItemSimilarity(itemID1, itemID2, preferring1, numUsers); } }
LogLikelihoodSimilarity extends AbstractItemSimilarity implements UserSimilarity { @Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { DataModel dataModel = getDataModel(); long preferring1 = dataModel.getNumUsersWithPreferenceFor(itemID1); long numUsers = dataModel.getNumUsers(); return doItemSimilarity(itemID1, itemID2, preferring1, numUsers); } LogLikelihoodSimilarity(DataModel dataModel); }
LogLikelihoodSimilarity extends AbstractItemSimilarity implements UserSimilarity { @Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { DataModel dataModel = getDataModel(); long preferring1 = dataModel.getNumUsersWithPreferenceFor(itemID1); long numUsers = dataModel.getNumUsers(); return doItemSimilarity(itemID1, itemID2, preferring1, numUsers); } LogLikelihoodSimilarity(DataModel dataModel); @Override void setPreferenceInferrer(PreferenceInferrer inferrer); @Override double userSimilarity(long userID1, long userID2); @Override double itemSimilarity(long itemID1, long itemID2); @Override double[] itemSimilarities(long itemID1, long[] itemID2s); @Override void refresh(Collection<Refreshable> alreadyRefreshed); @Override String toString(); }
LogLikelihoodSimilarity extends AbstractItemSimilarity implements UserSimilarity { @Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { DataModel dataModel = getDataModel(); long preferring1 = dataModel.getNumUsersWithPreferenceFor(itemID1); long numUsers = dataModel.getNumUsers(); return doItemSimilarity(itemID1, itemID2, preferring1, numUsers); } LogLikelihoodSimilarity(DataModel dataModel); @Override void setPreferenceInferrer(PreferenceInferrer inferrer); @Override double userSimilarity(long userID1, long userID2); @Override double itemSimilarity(long itemID1, long itemID2); @Override double[] itemSimilarities(long itemID1, long[] itemID2s); @Override void refresh(Collection<Refreshable> alreadyRefreshed); @Override String toString();  }