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

Hui Wen Han edited comment on MAHOUT-463 at 8/12/10 3:13 AM:
-------------------------------------------------------------

in Classs PrefsToItemUserMatrixMapper:

public class PrefsToItemUserMatrixMapper

    extends 
Mapper<LongWritable,Text,VarIntWritable,DistributedRowMatrix.MatrixEntryWritable>
 {


  @Override

  protected void map(LongWritable key, Text value, Context ctx)

      throws IOException, InterruptedException {


    String[] tokens = TasteHadoopUtils.splitPrefTokens(value.toString());

    long userID = Long.parseLong(tokens[0]);

    long itemID = Long.parseLong(tokens[1]);

    float prefValue = tokens.length > 2 ? Float.parseFloat(tokens[2]) : 1.0f;


    int row = TasteHadoopUtils.idToIndex(itemID);

    int column = TasteHadoopUtils.idToIndex(userID);


    DistributedRowMatrix.MatrixEntryWritable entry = new 
DistributedRowMatrix.MatrixEntryWritable();

    entry.setRow(row);

    entry.setCol(column);

    entry.setVal(prefValue);

    ctx.write(new VarIntWritable(row), entry);

  }

}

if it's boolean data ,also need set prefValue =1.0f


      was (Author: huiwenhan):
    in Classs PrefsToItemUserMatrixMapper:

public class PrefsToItemUserMatrixMapper
    extends 
Mapper<LongWritable,Text,VarIntWritable,DistributedRowMatrix.MatrixEntryWritable>
 {

  @Override
  protected void map(LongWritable key, Text value, Context ctx)
      throws IOException, InterruptedException {

    String[] tokens = TasteHadoopUtils.splitPrefTokens(value.toString());
    long userID = Long.parseLong(tokens[0]);
    long itemID = Long.parseLong(tokens[1]);
    float prefValue = tokens.length > 2 ? Float.parseFloat(tokens[2]) : 1.0f;

    int row = TasteHadoopUtils.idToIndex(itemID);
    int column = TasteHadoopUtils.idToIndex(userID);

    DistributedRowMatrix.MatrixEntryWritable entry = new 
DistributedRowMatrix.MatrixEntryWritable();
    entry.setRow(row);
    entry.setCol(column);
    entry.setVal(prefValue);

    ctx.write(new VarIntWritable(row), entry);
  }

}

if it's boolean data ,also need set prefValue =1.0f

  
> Boolean Data can not get any recommendation by running RecommnenderJob
> ----------------------------------------------------------------------
>
>                 Key: MAHOUT-463
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-463
>             Project: Mahout
>          Issue Type: Test
>          Components: Collaborative Filtering
>    Affects Versions: 0.4
>            Reporter: Hui Wen Han
>             Fix For: 0.4
>
>         Attachments: MAHOUT-463.patch
>
>
> Boolean Preference Data can not get any recommendation by run RecommnenderJob,
> but It can get data using the build in about Aprl.
> It seems that it can not get any data by running RowSimilarityJob 

-- 
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