Package org.apache.mahout.cf.taste.common

Examples of org.apache.mahout.cf.taste.common.NoSuchItemException


          anonymousUserFeatures[i] += (float) (signedFoldInWeight * userFoldIn[i]);
        }
      }
    }
    if (!anyItemIDFound) {
      throw new NoSuchItemException(Arrays.toString(itemIDs));
    }

    return anonymousUserFeatures;
  }
View Full Code Here


    } finally {
      yLock.unlock();
    }
   
    if (toItemFeatures == null) {
      throw new NoSuchItemException(toItemID);
    }
   
    float[] anonymousUserFeatures = buildAnonymousUserFeatures(itemIDs, values);   
   
    return (float) SimpleVectorMath.dot(anonymousUserFeatures, toItemFeatures);
View Full Code Here

    yLock.lock();
    try {

      float[] itemFeatures = Y.get(itemID);
      if (itemFeatures == null) {
        throw new NoSuchItemException(itemID);
      }

      return TopN.selectTopN(new MostSimilarItemIterator(Y.entrySet().iterator(),
                                                         generation.getUserTagIDs(),
                                                         new long[] { itemID },
View Full Code Here

        if (features != null) {
          itemFeatures.add(features);
        }
      }
      if (itemFeatures.isEmpty()) {
        throw new NoSuchItemException(Arrays.toString(itemIDs));
      }
      float[][] itemFeaturesArray = itemFeatures.toArray(new float[itemFeatures.size()][]);

      return TopN.selectTopN(new MostSimilarItemIterator(Y.entrySet().iterator(),
                                                         generation.getUserTagIDs(),
View Full Code Here

    yLock.lock();
    try {

      float[] toFeatures = Y.get(toItemID);
      if (toFeatures == null) {
        throw new NoSuchItemException(toItemID);
      }
      double toFeaturesNorm = SimpleVectorMath.norm(toFeatures);

      boolean anyFound = false;
      for (int i = 0; i < similarities.length; i++) {
        float[] features = Y.get(itemIDs[i]);
        if (features == null) {
          similarities[i] = Float.NaN;
        } else {
          anyFound = true;
          double featuresNorm = SimpleVectorMath.norm(features);
          similarities[i] = (float) (SimpleVectorMath.dot(features, toFeatures) / (featuresNorm * toFeaturesNorm));
        }
      }
      if (!anyFound) {
        throw new NoSuchItemException(Arrays.toString(itemIDs));
      }

    } finally {
      yLock.unlock();
    }
View Full Code Here

    yLock.lock();
    try {

      float[] features = Y.get(itemID);
      if (features == null) {
        throw new NoSuchItemException(itemID);
      }
      FastByIDMap<float[]> toFeatures;
      synchronized (userKnownItemIDs) {
        toFeatures = new FastByIDMap<float[]>(userKnownItemIDs.size());
        LongPrimitiveIterator it = userKnownItemIDs.iterator();
View Full Code Here

              return LangUtils.parseFloat(reader.readLine());
            } finally {
              reader.close();
            }
          case HttpURLConnection.HTTP_NOT_FOUND:
            throw new NoSuchItemException(Arrays.toString(itemIDs) + ' ' + toItemID);
          case HttpURLConnection.HTTP_UNAVAILABLE:
            throw new NotReadyException();
          default:
            throw new TasteException(connection.getResponseCode() + " " + connection.getResponseMessage());
        }
View Full Code Here

        connection = buildConnectionToReplica(replica, urlPath.toString(), "GET");
        switch (connection.getResponseCode()) {
          case HttpURLConnection.HTTP_OK:
            return consumeItems(connection);
          case HttpURLConnection.HTTP_NOT_FOUND:
            throw new NoSuchItemException(Arrays.toString(itemIDs));
          case HttpURLConnection.HTTP_UNAVAILABLE:
            throw new NotReadyException();
          default:
            throw new TasteException(connection.getResponseCode() + " " + connection.getResponseMessage());
        }
View Full Code Here

              return result;
            } finally {
              reader.close();
            }
          case HttpURLConnection.HTTP_NOT_FOUND:
            throw new NoSuchItemException(connection.getResponseMessage());
          case HttpURLConnection.HTTP_UNAVAILABLE:
            throw new NotReadyException();
          default:
            throw new TasteException(connection.getResponseCode() + " " + connection.getResponseMessage());
        }
View Full Code Here

            String connectionMessage = connection.getResponseMessage();
            if (connectionMessage != null &&
                connectionMessage.contains(NoSuchUserException.class.getSimpleName())) {
              throw new NoSuchUserException(userID);
            } else {
              throw new NoSuchItemException(itemID);
            }
          case HttpURLConnection.HTTP_UNAVAILABLE:
            throw new NotReadyException();
          default:
            throw new TasteException(connection.getResponseCode() + " " + connection.getResponseMessage());
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.common.NoSuchItemException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.