mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r833159 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste: impl/recommender/slopeone/MemoryDiffStorage.java model/DataModel.java
Date Thu, 05 Nov 2009 20:50:17 GMT
Author: srowen
Date: Thu Nov  5 20:50:17 2009
New Revision: 833159

URL: http://svn.apache.org/viewvc?rev=833159&view=rev
Log:
MAHOUT-195: improve docs about assuming DataModel.getPreferencesFromUser() returns prefs in
order, and, use that a little better in MemoryDiffStorage

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java?rev=833159&r1=833158&r2=833159&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
Thu Nov  5 20:50:17 2009
@@ -117,19 +117,20 @@
 
   @Override
   public RunningAverage getDiff(long itemID1, long itemID2) {
+
+    boolean inverted = false;
+    if (itemID1 > itemID2) {
+      inverted = true;
+      long temp = itemID1;
+      itemID1 = itemID2;
+      itemID2 = temp;
+    }
+
     FastByIDMap<RunningAverage> level2Map = averageDiffs.get(itemID1);
     RunningAverage average = null;
     if (level2Map != null) {
       average = level2Map.get(itemID2);
     }
-    boolean inverted = false;
-    if (average == null) {
-      level2Map = averageDiffs.get(itemID2);
-      if (level2Map != null) {
-        average = level2Map.get(itemID1);
-        inverted = true;
-      }
-    }
     if (inverted) {
       if (average == null) {
         return null;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java?rev=833159&r1=833158&r2=833159&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java
Thu Nov  5 20:50:17 2009
@@ -40,7 +40,7 @@
 
   /**
    * @param userID ID of user to get prefs for
-   * @return user's preferences
+   * @return user's preferences, ordered by item ID
    * @throws NoSuchUserException if the user does not exist
    * @throws TasteException if an error occurs while accessing the data
    */



Mime
View raw message