mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r736782 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste: common/ impl/eval/ impl/model/ impl/model/jdbc/ impl/recommender/ impl/recommender/slopeone/ model/
Date Thu, 22 Jan 2009 20:28:13 GMT
Author: srowen
Date: Thu Jan 22 12:28:12 2009
New Revision: 736782

URL: http://svn.apache.org/viewvc?rev=736782&view=rev
Log:
Introduce NoSuchUserException, NoSuchItemException

Added:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchItemException.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchUserException.java
      - copied, changed from r730810, lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/BooleanUserGenericDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/model/DataModel.java

Added: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchItemException.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchItemException.java?rev=736782&view=auto
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchItemException.java
(added)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchItemException.java
Thu Jan 22 12:28:12 2009
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.common;
+
+public final class NoSuchItemException extends TasteException {
+
+  public NoSuchItemException() {
+  }
+
+  public NoSuchItemException(String message) {
+    super(message);
+  }
+
+}
\ No newline at end of file

Copied: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchUserException.java
(from r730810, lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java)
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchUserException.java?p2=lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchUserException.java&p1=lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java&r1=730810&r2=736782&rev=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/NoSuchUserException.java
Thu Jan 22 12:28:12 2009
@@ -17,24 +17,13 @@
 
 package org.apache.mahout.cf.taste.common;
 
-/**
- * <p>An exception thrown when an error occurs inside the Taste engine.</p>
- */
-public final class TasteException extends Exception {
+public final class NoSuchUserException extends TasteException {
 
-  public TasteException() {
+  public NoSuchUserException() {
   }
 
-  public TasteException(String message) {
+  public NoSuchUserException(String message) {
     super(message);
   }
 
-  public TasteException(Throwable cause) {
-    super(cause);
-  }
-
-  public TasteException(String message, Throwable cause) {
-    super(message, cause);
-  }
-
-}
+}
\ No newline at end of file

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/common/TasteException.java
Thu Jan 22 12:28:12 2009
@@ -20,7 +20,7 @@
 /**
  * <p>An exception thrown when an error occurs inside the Taste engine.</p>
  */
-public final class TasteException extends Exception {
+public class TasteException extends Exception {
 
   public TasteException() {
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluator.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluator.java
Thu Jan 22 12:28:12 2009
@@ -18,6 +18,7 @@
 package org.apache.mahout.cf.taste.impl.eval;
 
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -28,7 +29,6 @@
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.NoSuchElementException;
 
 /**
  * <p>A {@link org.apache.mahout.cf.taste.eval.RecommenderEvaluator} which computes
the average absolute difference
@@ -54,7 +54,7 @@
           if (!Double.isNaN(estimatedPreference)) {
             average.addDatum(Math.abs(realPref.getValue() - estimatedPreference));
           }
-        } catch (NoSuchElementException nsee) {
+        } catch (NoSuchUserException nsee) {
           // It's possible that an item exists in the test data but not training data in
which case
           // NSEE will be thrown. Just ignore it and move on.
           log.info("Element exists in test data but not training data: {}", testUser.getID(),
nsee);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
Thu Jan 22 12:28:12 2009
@@ -18,6 +18,7 @@
 package org.apache.mahout.cf.taste.impl.eval;
 
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.eval.IRStatistics;
 import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
 import org.apache.mahout.cf.taste.eval.RecommenderIRStatsEvaluator;
@@ -42,7 +43,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.Random;
 
 /**
@@ -124,7 +124,7 @@
 
           try {
             trainingModel.getUser(id);
-          } catch (NoSuchElementException nsee) {
+          } catch (NoSuchUserException nsee) {
             continue; // Oops we excluded all prefs for the user -- just move on
           }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluator.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluator.java
Thu Jan 22 12:28:12 2009
@@ -18,6 +18,7 @@
 package org.apache.mahout.cf.taste.impl.eval;
 
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -28,7 +29,6 @@
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.NoSuchElementException;
 
 /**
  * <p>A {@link org.apache.mahout.cf.taste.eval.RecommenderEvaluator} which computes
the "root mean squared" difference
@@ -54,7 +54,7 @@
             double diff = realPref.getValue() - estimatedPreference;
             average.addDatum(diff * diff);
           }
-        } catch (NoSuchElementException nsee) {
+        } catch (NoSuchUserException nsee) {
           // It's possible that an item exists in the test data but not training data in
which case
           // NSEE will be thrown. Just ignore it and move on.
           log.info("Element exists in test data but not training data: {}", testUser.getID(),
nsee);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/BooleanUserGenericDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/BooleanUserGenericDataModel.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/BooleanUserGenericDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/BooleanUserGenericDataModel.java
Thu Jan 22 12:28:12 2009
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.FastSet;
 import org.apache.mahout.cf.taste.model.DataModel;
@@ -75,10 +76,10 @@
   }
 
   @Override
-  public User getUser(Object id) {
+  public User getUser(Object id) throws NoSuchUserException {
     User user = userMap.get(id);
     if (user == null) {
-      throw new NoSuchElementException();
+      throw new NoSuchUserException();
     }
     return user;
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
Thu Jan 22 12:28:12 2009
@@ -19,6 +19,8 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
+import org.apache.mahout.cf.taste.common.NoSuchItemException;
 import org.apache.mahout.cf.taste.impl.common.ArrayIterator;
 import org.apache.mahout.cf.taste.impl.common.EmptyIterable;
 import org.apache.mahout.cf.taste.impl.common.FastMap;
@@ -35,7 +37,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.Set;
 
 /**
@@ -123,13 +124,13 @@
   }
 
   /**
-   * @throws NoSuchElementException if there is no such {@link User}
+   * @throws NoSuchUserException if there is no such {@link User}
    */
   @Override
-  public User getUser(Object id) {
+  public User getUser(Object id) throws NoSuchUserException {
     User user = userMap.get(id);
     if (user == null) {
-      throw new NoSuchElementException();
+      throw new NoSuchUserException();
     }
     return user;
   }
@@ -140,13 +141,13 @@
   }
 
   /**
-   * @throws NoSuchElementException if there is no such {@link Item}
+   * @throws NoSuchItemException if there is no such {@link Item}
    */
   @Override
-  public Item getItem(Object id) {
+  public Item getItem(Object id) throws NoSuchItemException {
     Item item = itemMap.get(id);
     if (item == null) {
-      throw new NoSuchElementException();
+      throw new NoSuchItemException();
     }
     return item;
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
Thu Jan 22 12:28:12 2009
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.IOUtils;
 import org.apache.mahout.cf.taste.impl.common.IteratorIterable;
 import org.apache.mahout.cf.taste.impl.model.GenericItem;
@@ -249,7 +250,7 @@
   }
 
   /**
-   * @throws NoSuchElementException if there is no such user
+   * @throws NoSuchUserException if there is no such user
    */
   @Override
   public final User getUser(Object id) throws TasteException {
@@ -276,7 +277,7 @@
       }
 
       if (prefs.isEmpty()) {
-        throw new NoSuchElementException();
+        throw new NoSuchUserException();
       }
 
       return buildUser(idString, prefs);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
Thu Jan 22 12:28:12 2009
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RefreshHelper;
@@ -35,7 +36,6 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -151,7 +151,7 @@
       User theUser = dataModel.getUser(userID);
       Preference oldPref = theUser.getPreferenceFor(itemID);
       prefDelta = oldPref == null ? value : value - oldPref.getValue();
-    } catch (NoSuchElementException nsee) {
+    } catch (NoSuchUserException nsee) {
       prefDelta = value;
     }
     super.setPreference(userID, itemID, value);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
Thu Jan 22 12:28:12 2009
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RefreshHelper;
@@ -35,7 +36,6 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -174,7 +174,7 @@
       User theUser = dataModel.getUser(userID);
       Preference oldPref = theUser.getPreferenceFor(itemID);
       prefDelta = oldPref == null ? value : value - oldPref.getValue();
-    } catch (NoSuchElementException nsee) {
+    } catch (NoSuchUserException nsee) {
       prefDelta = value;
     }
     super.setPreference(userID, itemID, value);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommender.java?rev=736782&r1=736781&r2=736782&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommender.java
Thu Jan 22 12:28:12 2009
@@ -20,6 +20,7 @@
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.common.Weighting;
+import org.apache.mahout.cf.taste.common.NoSuchUserException;
 import org.apache.mahout.cf.taste.impl.common.RefreshHelper;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RunningAverageAndStdDev;
@@ -37,7 +38,6 @@
 
 import java.util.Collection;
 import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.Set;
 
 /**
@@ -178,7 +178,7 @@
       User theUser = dataModel.getUser(userID);
       Preference oldPref = theUser.getPreferenceFor(itemID);
       prefDelta = oldPref == null ? value : value - oldPref.getValue();
-    } catch (NoSuchElementException nsee) {
+    } catch (NoSuchUserException nsee) {
       prefDelta = value;
     }
     super.setPreference(userID, itemID, value);

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=736782&r1=736781&r2=736782&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 Jan 22 12:28:12 2009
@@ -38,7 +38,7 @@
    * @param id user ID
    * @return {@link User} who has that ID
    * @throws TasteException if an error occurs while accessing the data
-   * @throws java.util.NoSuchElementException if there is no such {@link User}
+   * @throws org.apache.mahout.cf.taste.common.NoSuchUserException if there is no such {@link
User}
    */
   User getUser(Object id) throws TasteException;
 
@@ -52,7 +52,7 @@
    * @param id item ID
    * @return {@link Item} that has that ID
    * @throws TasteException if an error occurs while accessing the data
-   * @throws java.util.NoSuchElementException if there is no such {@link Item}
+   * @throws org.apache.mahout.cf.taste.common.NoSuchItemException if there is no such {@link
Item}
    */
   Item getItem(Object id) throws TasteException;
 



Mime
View raw message