mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r735303 - in /lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix: NetflixDataModel.java NetflixFileDataModel.java NetflixRecommender.java NetflixRecommenderBuilder.java NetflixRecommenderEvaluatorRunner.java
Date Sat, 17 Jan 2009 15:15:17 GMT
Author: srowen
Date: Sat Jan 17 07:15:17 2009
New Revision: 735303

URL: http://svn.apache.org/viewvc?rev=735303&view=rev
Log: (empty)

Added:
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommender.java
      - copied, changed from r731349, 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/netflix/NetflixRecommenderBuilder.java
      - copied, changed from r731349, lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderBuilder.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderEvaluatorRunner.java
      - copied, changed from r731349, lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java
Modified:
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixFileDataModel.java

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java?rev=735303&r1=735302&r2=735303&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java
Sat Jan 17 07:15:17 2009
@@ -119,18 +119,6 @@
 		return users;
 	}
 
-	private static List<NetflixMovie> readMovies(File dataDirectory) {
-		List<NetflixMovie> movies = new ArrayList<NetflixMovie>();
-    for (String line : new FileLineIterable(new File(dataDirectory, "movie_titles.txt"),
false)) {
-			int firstComma = line.indexOf((int) ',');
-			Integer id = Integer.valueOf(line.substring(0, firstComma));
-			int secondComma = line.indexOf((int) ',', firstComma + 1);
-			String title = line.substring(secondComma + 1);
-			movies.add(new NetflixMovie(id, title));
-		}
-		return movies;
-	}
-
 	@Override
   public Iterable<? extends User> getUsers() throws TasteException {
 		return delegate.getUsers();
@@ -197,4 +185,10 @@
       return filename.startsWith(useSubset ? "mv_0000" : "mv_");
     }
   }
+
+  @Override
+  public String toString() {
+    return "NetflixDataModel";
+  }
+
 }

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixFileDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixFileDataModel.java?rev=735303&r1=735302&r2=735303&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixFileDataModel.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixFileDataModel.java
Sat Jan 17 07:15:17 2009
@@ -131,4 +131,9 @@
     // do nothing
   }
 
+  @Override
+  public String toString() {
+    return "NetflixFileDataModel";
+  }
+
 }

Copied: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommender.java
(from r731349, 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/netflix/NetflixRecommender.java?p2=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommender.java&p1=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java&r1=731349&r2=735303&rev=735303&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/netflix/NetflixRecommender.java
Sat Jan 17 07:15:17 2009
@@ -15,36 +15,26 @@
  * limitations under the License.
  */
 
-package org.apache.mahout.cf.taste.example.bookcrossing;
+package org.apache.mahout.cf.taste.example.netflix;
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-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.neighborhood.NearestNUserNeighborhood;
+import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
-import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
-import org.apache.mahout.cf.taste.similarity.UserSimilarity;
 
 import java.util.Collection;
 import java.util.List;
 
-/**
- * A simple {@link Recommender} implemented for the Book Crossing demo.
- * See the <a href="http://www.informatik.uni-freiburg.de/~cziegler/BX/">Book Crossing
site</a>.
- */
-public final class BookCrossingRecommender implements Recommender {
+public final class NetflixRecommender implements Recommender {
 
   private final Recommender recommender;
 
-  public BookCrossingRecommender(DataModel dataModel, BookCrossingDataModel bcModel) throws
TasteException {
-    UserSimilarity similarity = new GeoUserSimilarity(bcModel);
-    UserNeighborhood neighborhood = new NearestNUserNeighborhood(5, similarity, dataModel);
-    recommender = new CachingRecommender(new GenericUserBasedRecommender(dataModel, neighborhood,
similarity));
+  public NetflixRecommender(DataModel dataModel) throws TasteException {
+    recommender = new SlopeOneRecommender(dataModel);
   }
 
   @Override

Copied: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderBuilder.java
(from r731349, lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderBuilder.java)
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderBuilder.java?p2=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderBuilder.java&p1=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderBuilder.java&r1=731349&r2=735303&rev=735303&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderBuilder.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderBuilder.java
Sat Jan 17 07:15:17 2009
@@ -15,24 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.mahout.cf.taste.example.bookcrossing;
+package org.apache.mahout.cf.taste.example.netflix;
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 
-final class BookCrossingRecommenderBuilder implements RecommenderBuilder {
-
-  private final BookCrossingDataModel bcModel;
-
-  BookCrossingRecommenderBuilder(BookCrossingDataModel bcModel) {
-    this.bcModel = bcModel;
-  }
+final class NetflixRecommenderBuilder implements RecommenderBuilder {
 
   @Override
   public Recommender buildRecommender(DataModel dataModel) throws TasteException {
-    return new BookCrossingRecommender(dataModel, bcModel);
+    return new NetflixRecommender(dataModel);
   }
 
 }
\ No newline at end of file

Copied: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderEvaluatorRunner.java
(from r731349, 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/netflix/NetflixRecommenderEvaluatorRunner.java?p2=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixRecommenderEvaluatorRunner.java&p1=lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommenderEvaluatorRunner.java&r1=731349&r2=735303&rev=735303&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/netflix/NetflixRecommenderEvaluatorRunner.java
Sat Jan 17 07:15:17 2009
@@ -15,35 +15,30 @@
  * limitations under the License.
  */
 
-package org.apache.mahout.cf.taste.example.bookcrossing;
+package org.apache.mahout.cf.taste.example.netflix;
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.eval.RecommenderEvaluator;
 import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator;
+import org.apache.mahout.cf.taste.model.DataModel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.io.File;
 
-/**
- * <p>A simple example "runner" class which will evaluate the performance of the current
- * implementation of {@link org.apache.mahout.cf.taste.example.grouplens.GroupLensRecommender}.</p>
- */
-public final class BookCrossingRecommenderEvaluatorRunner {
+public final class NetflixRecommenderEvaluatorRunner {
 
-  private static final Logger log = LoggerFactory.getLogger(BookCrossingRecommenderEvaluatorRunner.class);
+  private static final Logger log = LoggerFactory.getLogger(NetflixRecommenderEvaluatorRunner.class);
 
-  private BookCrossingRecommenderEvaluatorRunner() {
+  private NetflixRecommenderEvaluatorRunner() {
     // do nothing
   }
 
   public static void main(String... args) throws IOException, TasteException {
     RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
-    BookCrossingDataModel model = new BookCrossingDataModel();
-    double evaluation = evaluator.evaluate(new BookCrossingRecommenderBuilder(model),
-                                                 model,
-                                                 0.9,
-                                                 0.1);
+    DataModel model = new NetflixDataModel(new File(args[0]), true);
+    double evaluation = evaluator.evaluate(new NetflixRecommenderBuilder(), model, 0.9, 0.1);
     log.info(String.valueOf(evaluation));
   }
 



Mime
View raw message