[ 
https://issues.apache.org/jira/browse/MAHOUT-358?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12854383#action_12854383
 ] 

Hui Wen Han commented on MAHOUT-358:
------------------------------------

I have some finding :

I debug as following:
code:
  public void map(LongWritable userID,
                  VectorWritable vectorWritable,
                  OutputCollector<LongWritable,RecommendedItemsWritable> output,
                  Reporter reporter) throws IOException {
    
    if ((usersToRecommendFor != null) && 
!usersToRecommendFor.contains(userID.get())) {
      return;
    }
    System.out.println("user_id:start-----------"+userID.get());
    Vector userVector = vectorWritable.get();
    Iterator<Vector.Element> userVectorIterator = userVector.iterateNonZero();
    Vector recommendationVector = new 
RandomAccessSparseVector(Integer.MAX_VALUE, 1000);
    while (userVectorIterator.hasNext()) {
      Vector.Element element = userVectorIterator.next();
      int index = element.index();
      Vector columnVector;
      try {
        columnVector = cooccurrenceColumnCache.get(new IntWritable(index));
      } catch (TasteException te) {
        if (te.getCause() instanceof IOException) {
          throw (IOException) te.getCause();
        } else {
          throw new IOException(te.getCause());
        }
      }
      if (columnVector != null) {
          Iterator<Vector.Element> columnVectorIterator = 
columnVector.iterateNonZero();  //debug here
          while (columnVectorIterator.hasNext()) {
              Vector.Element element1 = columnVectorIterator.next();
              int index1 = element1.index();
              double value1 = element1.get();
              System.out.println("before index["+index1+"]:"+value1);
          }
        if (booleanData) { // because 'value' is 1.0
          columnVector.addTo(recommendationVector);
        } else {
          double value = element.get();
          System.out.println(value);
          columnVector.times(value).addTo(recommendationVector);
        }
      }
    }
    Iterator<Vector.Element> recVectorIterator = 
recommendationVector.iterateNonZero();  //debug here
          while (recVectorIterator.hasNext()) {
              Vector.Element element2 = recVectorIterator.next();
              int index2 = element2.index();
              double value2 = element2.get();
              System.out.println("after inex["+index2+"]:"+value2);
          }
    Queue<RecommendedItem> topItems = new 
PriorityQueue<RecommendedItem>(recommendationsPerUser + 1,
        Collections.reverseOrder());
    
    Iterator<Vector.Element> recommendationVectorIterator = 
recommendationVector.iterateNonZero();
    LongWritable itemID = new LongWritable();
    while (recommendationVectorIterator.hasNext()) {
      Vector.Element element = recommendationVectorIterator.next();
      int index = element.index();
      if (userVector.get(index) == 0.0) {
        if (topItems.size() < recommendationsPerUser) {
          indexItemIDMap.get(new IntWritable(index), itemID);
          topItems.add(new GenericRecommendedItem(itemID.get(), (float) 
element.get()));
        } else if (element.get() > topItems.peek().getValue()) {
          indexItemIDMap.get(new IntWritable(index), itemID);
          topItems.add(new GenericRecommendedItem(itemID.get(), (float) 
element.get()));
          topItems.poll();
        }
      }
    }
    
    List<RecommendedItem> recommendations = new 
ArrayList<RecommendedItem>(topItems.size());
    recommendations.addAll(topItems);
    Collections.sort(recommendations);
    output.collect(userID, new RecommendedItemsWritable(recommendations));
    for (RecommendedItem recommendation : recommendations)
    { 
        
System.out.println(recommendation.getItemID()+":"+recommendation.getValue());   
//debug here
        //user.set(String.valueOf(userID)); 
        //recomScore.set(recommendation.getItemID() + FIELD_SEPERATOR + 
recommendation.getValue()); 
        //output.collect(user, recomScore); 
    } 
    System.out.println("user_id:end-----------"+userID.get());
  }

add the out put and the log in attachment 

> the pref value  field of output of 
> org.apache.mahout.cf.taste.hadoop.item.RecommenderJob has negative
> -----------------------------------------------------------------------------------------------------
>
>                 Key: MAHOUT-358
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-358
>             Project: Mahout
>          Issue Type: Test
>          Components: Collaborative Filtering
>    Affects Versions: 0.4
>            Reporter: Hui Wen Han
>         Attachments: screenshot-1.jpg, screenshot-2.jpg
>
>
> In my test the input pref values all is positive.
> the output score value has negative value ,

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to