Examples of assignRow()


Examples of org.apache.mahout.math.DenseMatrix.assignRow()

    // build in-memory data matrix A
    Matrix a = new DenseMatrix(sampleData.size(), sampleDimension);
    int i = 0;
    for (VectorWritable vw : sampleData) {
      a.assignRow(i++, vw.get());
    }
    // extract the eigenvectors into P
    Matrix p = new DenseMatrix(39, desiredRank - 1);
    FileSystem fs = FileSystem.get(cleanEigenvectors.toUri(), conf);
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, cleanEigenvectors, conf);
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

    Configuration conf = new Configuration();

    int i = 0;
    for (VectorWritable value : new SequenceFileValueIterable<VectorWritable>(rawEigenvectors, conf)) {
      Vector v = value.get();
      eigenVectors.assignRow(i, v);
      i++;
    }
    assertEquals("number of eigenvectors", 7, i);
  }
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

    i = 0;
    for (VectorWritable value : new SequenceFileValueIterable<VectorWritable>(cleanEigenvectors2, conf)) {
      NamedVector v = (NamedVector) value.get();
      log.info(v.getName());
      eigenVectors2.assignRow(i, v);
      newEigenValues.add(EigenVector.getEigenValue(v.getName()));
      i++;
    }

    Collection<Integer> oldEigensFound = Lists.newArrayList();
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

   
    // build in-memory data matrix A
    Matrix a = new DenseMatrix(sampleData.size(), sampleDimension);
    int i = 0;
    for (VectorWritable vw : sampleData) {
      a.assignRow(i++, vw.get());
    }
    // extract the eigenvectors into P
    Matrix p = new DenseMatrix(39, desiredRank - 1);
    FileSystem fs = FileSystem.get(cleanEigenvectors.toUri(), conf);
   
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

      for(int col = 0; col < numCols; col++) {
        double val = r.nextGaussian();
        v.set(col, val);
      }
      v.assign(Functions.MULT, 1/((row + 1) * v.norm(2)));
      matrix.assignRow(row, v);
    }
    if(symmetric) {
      return matrix.times(matrix.transpose());
    }
    return matrix;
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

      Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
      Writable value = reader.getValueClass().asSubclass(Writable.class).newInstance();
      int i = 0;
      while (reader.next(key, value)) {
        Vector v = ((VectorWritable) value).get();
        eigenVectors.assignRow(i, v);
        System.out.println("k=" + key.toString() + " V=" + AbstractCluster.formatVector(v, null));
        value = reader.getValueClass().asSubclass(Writable.class).newInstance();
        i++;
      }
      assertEquals("number of eigenvectors", 9, i);
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

      Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
      Writable value = reader.getValueClass().asSubclass(Writable.class).newInstance();
      int i = 0;
      while (reader.next(key, value)) {
        Vector v = ((VectorWritable) value).get();
        eigenVectors.assignRow(i, v);
        System.out.println("k=" + key.toString() + " V=" + AbstractCluster.formatVector(v, null));
        value = reader.getValueClass().asSubclass(Writable.class).newInstance();
        i++;
      }
      assertEquals("number of clean eigenvectors", 4, i);
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

   *         last category.
   */
  public Matrix classify(Matrix data) {
    Matrix r = new DenseMatrix(data.numRows(), numCategories() - 1);
    for (int row = 0; row < data.numRows(); row++) {
      r.assignRow(row, classify(data.getRow(row)));
    }
    return r;
  }

  /**
 
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

   * @return A matrix of scores, one row per row of the input matrix, one column for each but the last category.
   */
  public Matrix classify(Matrix data) {
    Matrix r = new DenseMatrix(data.numRows(), numCategories() - 1);
    for (int row = 0; row < data.numRows(); row++) {
      r.assignRow(row, classify(data.viewRow(row)));
    }
    return r;
  }

  /**
 
View Full Code Here

Examples of org.apache.mahout.math.DenseMatrix.assignRow()

      for (int col = 0; col < numCols; col++) {
        double val = r.nextGaussian();
        v.set(col, val);
      }
      v.assign(Functions.MULT, 1/((row + 1) * v.norm(2)));
      matrix.assignRow(row, v);
    }
    if (symmetric) {
      return matrix.times(matrix.transpose());
    }
    return matrix;
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.