mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r921289 - in /lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example: bookcrossing/ jester/
Date Wed, 10 Mar 2010 10:26:19 GMT
Author: srowen
Date: Wed Mar 10 10:26:18 2010
New Revision: 921289

URL: http://svn.apache.org/viewvc?rev=921289&view=rev
Log:
Update examples to use a little more data for more consistent results

Modified:
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommenderEvaluatorRunner.java

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java?rev=921289&r1=921288&r2=921289&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java
Wed Mar 10 10:26:18 2010
@@ -25,6 +25,7 @@ import org.apache.mahout.cf.taste.common
 import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
 import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
 import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
+import org.apache.mahout.cf.taste.impl.similarity.CachingUserSimilarity;
 import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
@@ -42,8 +43,8 @@ public final class BookCrossingRecommend
   private final Recommender recommender;
   
   public BookCrossingRecommender(DataModel bcModel) throws TasteException {
-    UserSimilarity similarity = new PearsonCorrelationSimilarity(bcModel);
-    UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, 0.0, similarity, bcModel,
0.1);
+    UserSimilarity similarity = new CachingUserSimilarity(new PearsonCorrelationSimilarity(bcModel),
bcModel);
+    UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, 0.0, similarity, bcModel,
0.25);
     recommender = new CachingRecommender(new GenericUserBasedRecommender(bcModel, neighborhood,
similarity));
   }
   

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java?rev=921289&r1=921288&r2=921289&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java
Wed Mar 10 10:26:18 2010
@@ -50,8 +50,8 @@ public final class BookCrossingRecommend
     double evaluation = evaluator.evaluate(new BookCrossingRecommenderBuilder(),
       null,
       model,
-      0.95,
-      0.05);
+      0.9,
+      0.3);
     log.info(String.valueOf(evaluation));
   }
   

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java?rev=921289&r1=921288&r2=921289&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java
Wed Mar 10 10:26:18 2010
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.regex.Pattern;
 
 import org.apache.mahout.cf.taste.example.grouplens.GroupLensDataModel;
 import org.apache.mahout.cf.taste.impl.common.FastByIDMap;
@@ -32,7 +33,9 @@ import org.apache.mahout.cf.taste.model.
 import org.apache.mahout.common.FileLineIterator;
 
 public final class JesterDataModel extends FileDataModel {
-  
+
+  private static final Pattern COMMA_PATTERN = Pattern.compile(",");
+
   private long userBeingRead;
   
   public JesterDataModel() throws IOException {
@@ -64,7 +67,7 @@ public final class JesterDataModel exten
   @Override
   protected void processLine(String line, FastByIDMap<?> rawData, boolean fromPriorData)
{
     FastByIDMap<Collection<Preference>> data = (FastByIDMap<Collection<Preference>>)
rawData;
-    String[] jokePrefs = line.split(",");
+    String[] jokePrefs = COMMA_PATTERN.split(line);
     int count = Integer.parseInt(jokePrefs[0]);
     Collection<Preference> prefs = new ArrayList<Preference>(count);
     for (int itemID = 1; itemID < jokePrefs.length; itemID++) { // yes skip first one,
just a count

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommenderEvaluatorRunner.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommenderEvaluatorRunner.java?rev=921289&r1=921288&r2=921289&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommenderEvaluatorRunner.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommenderEvaluatorRunner.java
Wed Mar 10 10:26:18 2010
@@ -50,7 +50,7 @@ public final class JesterRecommenderEval
       null,
       model,
       0.9,
-      0.1);
+      0.3);
     log.info(String.valueOf(evaluation));
   }
   



Mime
View raw message