当前位置: 首页>>代码示例>>Java>>正文


Java RandomAccessSparseVector.setQuick方法代码示例

本文整理汇总了Java中org.apache.mahout.math.RandomAccessSparseVector.setQuick方法的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessSparseVector.setQuick方法的具体用法?Java RandomAccessSparseVector.setQuick怎么用?Java RandomAccessSparseVector.setQuick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mahout.math.RandomAccessSparseVector的用法示例。


在下文中一共展示了RandomAccessSparseVector.setQuick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reduce

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
@Override
protected void reduce(Text row, Iterable<VertexWritable> entries, 
    Context context) throws IOException, InterruptedException {
  // now to assemble the vectors
  RandomAccessSparseVector output = new RandomAccessSparseVector(
      context.getConfiguration().getInt(EigencutsKeys.AFFINITY_DIMENSIONS, Integer.MAX_VALUE), 100);
  int rownum = Integer.parseInt(row.toString());
  for (VertexWritable e : entries) {
    // first, are we setting a diagonal?
    if (e.getCol() == rownum) {
      // add to what's already present
      output.setQuick(e.getCol(), output.getQuick(e.getCol()) + e.getValue());
    } else {
      // simply set the value
      output.setQuick(e.getCol(), e.getValue());
    }
  }
  context.write(new IntWritable(rownum), new VectorWritable(output));
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:20,代码来源:EigencutsAffinityCutsJob.java

示例2: reduce

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
@Override
protected void reduce(IntWritable row, Iterable<DistributedRowMatrix.MatrixEntryWritable> values, Context context)
  throws IOException, InterruptedException {
  int size = context.getConfiguration().getInt(EigencutsKeys.AFFINITY_DIMENSIONS, Integer.MAX_VALUE);
  RandomAccessSparseVector out = new RandomAccessSparseVector(size, 100);

  for (DistributedRowMatrix.MatrixEntryWritable element : values) {
    out.setQuick(element.getCol(), element.getVal());
    if (log.isDebugEnabled()) {
      log.debug("(DEBUG - REDUCE) Row[{}], Column[{}], Value[{}]",
                new Object[] {row.get(), element.getCol(), element.getVal()});
    }
  }
  SequentialAccessSparseVector output = new SequentialAccessSparseVector(out);
  context.write(row, new VectorWritable(output));
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:17,代码来源:AffinityMatrixInputReducer.java

示例3: reduce

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
@Override
protected void reduce(SimilarityMatrixEntryKey key, Iterable<DistributedRowMatrix.MatrixEntryWritable> entries,
		Context ctx) throws IOException, InterruptedException
{
	RandomAccessSparseVector temporaryVector = new RandomAccessSparseVector(Integer.MAX_VALUE,
			maxSimilaritiesPerRow);
	int similaritiesSet = 0;
	for (DistributedRowMatrix.MatrixEntryWritable entry : entries)
	{
		temporaryVector.setQuick(entry.getCol(), entry.getVal());
		if (++similaritiesSet == maxSimilaritiesPerRow)
		{
			break;
		}
	}
	SequentialAccessSparseVector vector = new SequentialAccessSparseVector(temporaryVector);
	ctx.write(new IntWritable(key.getRow()), new VectorWritable(vector));
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:19,代码来源:RowSimilarityZieOok.java

示例4: map

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
@Override
protected void map(IntWritable r, VectorWritable v, Context ctx) throws IOException, InterruptedException {
  int row = r.get();
  Iterator<Vector.Element> it = v.get().iterateNonZero();
  while (it.hasNext()) {
    Vector.Element e = it.next();
    RandomAccessSparseVector tmp = new RandomAccessSparseVector(Integer.MAX_VALUE, 1);
    tmp.setQuick(row, e.get());
    r.set(e.index());
    ctx.write(r, new VectorWritable(tmp));
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:13,代码来源:TransposeMapper.java

示例5: writeVector

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
@Override
public void writeVector(MySparseVector vector) throws IOException {
    String docIdName = String.format("%09d", ++docId); //mahout stores doc ids as Text
    RandomAccessSparseVector vec = new RandomAccessSparseVector(termcount);
    for (int i = 0; i < vector.indices.size(); i++)
        vec.setQuick(vector.indices.get(i), vector.values.get(i));

    NamedVector nv = new NamedVector(vec, docIdName);
    tfidfWriter.append(new Text(docIdName), new VectorWritable(nv));
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:11,代码来源:MahoutOutput.java

示例6: testRankMapCreation

import org.apache.mahout.math.RandomAccessSparseVector; //导入方法依赖的package包/类
public void testRankMapCreation() {
    RandomAccessSparseVector vector = new RandomAccessSparseVector(10);
    vector.setQuick(1, 10);
    vector.setQuick(2, 5);
    vector.setQuick(3, -2);
    
    EvaluationUtils.RankMap rankMap = EvaluationUtils.getRankMap(vector);
    
    assertTrue(rankMap.get(1) == 0);
    assertTrue(rankMap.get(2) == 1);
    assertTrue(rankMap.get(4) == 5);
    assertTrue(rankMap.get(3) == 9);
}
 
开发者ID:maciejkula,项目名称:dictionarylearning,代码行数:14,代码来源:EvaluationUtilsTestCase.java


注:本文中的org.apache.mahout.math.RandomAccessSparseVector.setQuick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。