Package org.apache.mahout.clustering.spectral.MatrixDiagonalizeJob

Examples of org.apache.mahout.clustering.spectral.MatrixDiagonalizeJob.MatrixDiagonalizeMapper


    return sum;
  }

  @Test
  public void testMatrixDiagonalizeMapper() throws Exception {
    MatrixDiagonalizeMapper mapper = new MatrixDiagonalizeMapper();
    Configuration conf = getConfiguration();
    conf.setInt(Keys.AFFINITY_DIMENSIONS, RAW_DIMENSIONS);
   
    // set up the dummy writers
    DummyRecordWriter<NullWritable, IntDoublePairWritable> writer =
      new DummyRecordWriter<NullWritable, IntDoublePairWritable>();
    Mapper<IntWritable, VectorWritable, NullWritable, IntDoublePairWritable>.Context
      context = DummyRecordWriter.build(mapper, conf, writer);
   
    // perform the mapping
    for (int i = 0; i < RAW_DIMENSIONS; i++) {
      RandomAccessSparseVector toAdd = new RandomAccessSparseVector(RAW_DIMENSIONS);
      toAdd.assign(RAW[i]);
      mapper.map(new IntWritable(i), new VectorWritable(toAdd), context);
    }
   
    // check the number of the results
    assertEquals("Number of map results", RAW_DIMENSIONS,
        writer.getValue(NullWritable.get()).size());
View Full Code Here


        writer.getValue(NullWritable.get()).size());
  }
 
  @Test
public void testMatrixDiagonalizeReducer() throws Exception {
    MatrixDiagonalizeMapper mapper = new MatrixDiagonalizeMapper();
    Configuration conf = getConfiguration();
    conf.setInt(Keys.AFFINITY_DIMENSIONS, RAW_DIMENSIONS);
   
    // set up the dummy writers
    DummyRecordWriter<NullWritable, IntDoublePairWritable> mapWriter =
      new DummyRecordWriter<NullWritable, IntDoublePairWritable>();
    Mapper<IntWritable, VectorWritable, NullWritable, IntDoublePairWritable>.Context
      mapContext = DummyRecordWriter.build(mapper, conf, mapWriter);
   
    // perform the mapping
    for (int i = 0; i < RAW_DIMENSIONS; i++) {
      RandomAccessSparseVector toAdd = new RandomAccessSparseVector(RAW_DIMENSIONS);
      toAdd.assign(RAW[i]);
      mapper.map(new IntWritable(i), new VectorWritable(toAdd), mapContext);
    }
   
    // now perform the reduction
    MatrixDiagonalizeReducer reducer = new MatrixDiagonalizeReducer();
    DummyRecordWriter<NullWritable, VectorWritable> redWriter = new
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.spectral.MatrixDiagonalizeJob.MatrixDiagonalizeMapper

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.