Package org.apache.mahout.math

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()


    Path baseTmpDirPath = getTestTempDirPath("testpaths");
    Path inputPath = new Path(baseTmpDirPath, "input");
    Path outputPath = new Path(baseTmpDirPath, "output");

    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);

    Configuration timesSquaredJobConf1 = TimesSquaredJob.createTimesSquaredJobConf(v, inputPath, outputPath);
    Configuration customTimesSquaredJobConf1 = TimesSquaredJob.createTimesSquaredJobConf(initialConf, v, inputPath, outputPath);

    assertNull(timesSquaredJobConf1.get(TEST_PROPERTY_KEY));
View Full Code Here


  @Test
  public void testTimesVectorTempDirDeletion() throws Exception {
    Configuration conf = getConfiguration();
    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);
    DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false);
    dm.setConf(conf);

    Path outputPath = dm.getOutputTempPath();
    FileSystem fs = outputPath.getFileSystem(conf);
View Full Code Here

  @Test
  public void testTimesSquaredVectorTempDirDeletion() throws Exception {
    Configuration conf = getConfiguration();
    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);
    DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false);
    dm.setConf(getConfiguration());

    Path outputPath = dm.getOutputTempPath();
    FileSystem fs = outputPath.getFileSystem(conf);
View Full Code Here

  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

        return;
      }
      Vector accumulator = new RandomAccessSparseVector(it.next().get());
      while (it.hasNext()) {
        Vector row = it.next().get();
        accumulator.assign(row, Functions.PLUS);
      }
      out.collect(rowNum, new VectorWritable(new SequentialAccessSparseVector(accumulator)));
    }
  }
View Full Code Here

 
  private static List<VectorWritable> getPoints() {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : RAW) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

 
  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

 
  private static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

  protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
      InterruptedException {

    Vector vector = new RandomAccessSparseVector(dimension, 10);
    for (VectorWritable value : values) {
      vector.assign(value.get(), Functions.PLUS);
    }
    if (normPower != PartialVectorMerger.NO_NORMALIZING) {
      if (logNormalize) {
        vector = vector.logNormalize(normPower);
      } else {
View Full Code Here

 
  private static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.