mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r803142 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl: eval/LoadEvaluator.java similarity/GenericUserSimilarity.java
Date Tue, 11 Aug 2009 14:58:55 GMT
Author: srowen
Date: Tue Aug 11 14:58:55 2009
New Revision: 803142

URL: http://svn.apache.org/viewvc?rev=803142&view=rev
Log:
MAHOUT-158 cleanup: not sure how these files got missed

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/LoadEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericUserSimilarity.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/LoadEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/LoadEvaluator.java?rev=803142&r1=803141&r2=803142&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/LoadEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/LoadEvaluator.java
Tue Aug 11 14:58:55 2009
@@ -20,7 +20,8 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverageAndStdDev;
 import org.apache.mahout.cf.taste.impl.common.RunningAverageAndStdDev;
-import org.apache.mahout.cf.taste.impl.common.SamplingIterable;
+import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator;
+import org.apache.mahout.cf.taste.impl.common.SamplingLongPrimitiveIterator;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.slf4j.Logger;
@@ -35,12 +36,12 @@
     DataModel dataModel = recommender.getDataModel();
     int numUsers = dataModel.getNumUsers();
     double sampleRate = 1000.0 / numUsers;
-    SamplingIterable<Long> userSampler = new SamplingIterable<Long>(dataModel.getUserIDs(),
sampleRate);
+    LongPrimitiveIterator userSampler = SamplingLongPrimitiveIterator.maybeWrapIterator(dataModel.getUserIDs(),
sampleRate);
     RunningAverageAndStdDev recommendationTime = new FullRunningAverageAndStdDev();
     int count = 0;
-    for (long userID : userSampler) {
+    while (userSampler.hasNext()) {
       long start = System.currentTimeMillis();
-      recommender.recommend(userID, 10);
+      recommender.recommend(userSampler.next(), 10);
       long end = System.currentTimeMillis();
       if (count > 0) { // Ignore first as a warmup
         recommendationTime.addDatum(end - start);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericUserSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericUserSimilarity.java?rev=803142&r1=803141&r2=803142&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericUserSimilarity.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericUserSimilarity.java
Tue Aug 11 14:58:55 2009
@@ -47,14 +47,14 @@
   }
 
   public GenericUserSimilarity(UserSimilarity otherSimilarity, DataModel dataModel) throws
TasteException {
-    List<Long> userIDs = IteratorUtils.iterableToList(dataModel.getUserIDs());
+    long[] userIDs = IteratorUtils.longIteratorToList(dataModel.getUserIDs());
     Iterator<UserUserSimilarity> it = new DataModelSimilaritiesIterator(otherSimilarity,
userIDs);
     initSimilarityMaps(new IteratorIterable<UserUserSimilarity>(it));
   }
 
   public GenericUserSimilarity(UserSimilarity otherSimilarity, DataModel dataModel, int maxToKeep)
       throws TasteException {
-    List<Long> userIDs = IteratorUtils.iterableToList(dataModel.getUserIDs());
+    long[] userIDs = IteratorUtils.longIteratorToList(dataModel.getUserIDs());
     Iterator<UserUserSimilarity> it = new DataModelSimilaritiesIterator(otherSimilarity,
userIDs);
     Iterable<UserUserSimilarity> keptSimilarities =
         TopItems.getTopUserUserSimilarities(maxToKeep, new IteratorIterable<UserUserSimilarity>(it));
@@ -177,18 +177,18 @@
   private static final class DataModelSimilaritiesIterator implements Iterator<UserUserSimilarity>
{
 
     private final UserSimilarity otherSimilarity;
-    private final List<Long> userIDs;
+    private final long[] userIDs;
     private final int size;
     private int i;
     private long userID1;
     private int j;
 
-    private DataModelSimilaritiesIterator(UserSimilarity otherSimilarity, List<Long>
userIDs) {
+    private DataModelSimilaritiesIterator(UserSimilarity otherSimilarity, long[] userIDs)
{
       this.otherSimilarity = otherSimilarity;
       this.userIDs = userIDs;
-      this.size = userIDs.size();
+      this.size = userIDs.length;
       i = 0;
-      userID1 = userIDs.get(0);
+      userID1 = userIDs[0];
       j = 1;
     }
 
@@ -202,7 +202,7 @@
       if (!hasNext()) {
         throw new NoSuchElementException();
       }
-      long userID2 = userIDs.get(j);
+      long userID2 = userIDs[j];
       double similarity;
       try {
         similarity = otherSimilarity.userSimilarity(userID1, userID2);
@@ -214,7 +214,7 @@
       j++;
       if (j == size) {
         i++;
-        userID1 = userIDs.get(i);
+        userID1 = userIDs[i];
         j = i + 1;
       }
       return result;



Mime
View raw message