Package org.apache.mahout.clustering.spectral.common.UnitVectorizerJob

Examples of org.apache.mahout.clustering.spectral.common.UnitVectorizerJob.UnitVectorizerMapper


  private static final double [][] RAW = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };

  @Test
  public void testUnitVectorizerMapper() throws Exception {
    UnitVectorizerMapper mapper = new UnitVectorizerMapper();
    Configuration conf = new Configuration();
   
    // set up the dummy writers
    DummyRecordWriter<IntWritable, VectorWritable> writer = new
      DummyRecordWriter<IntWritable, VectorWritable>();
    Mapper<IntWritable, VectorWritable, IntWritable, VectorWritable>.Context
      context = DummyRecordWriter.build(mapper, conf, writer);
   
    // perform the mapping
    for (int i = 0; i < RAW.length; i++) {
      Vector vector = new RandomAccessSparseVector(RAW[i].length);
      vector.assign(RAW[i]);
      mapper.map(new IntWritable(i), new VectorWritable(vector), context);
    }
   
    // check the results
    assertEquals("Number of map results", RAW.length, writer.getData().size());
    for (int i = 0; i < RAW.length; i++) {
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.spectral.common.UnitVectorizerJob.UnitVectorizerMapper

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.