Examples of numRows()


Examples of org.apache.mahout.math.Matrix.numRows()

    startTime(TimingSection.FINAL_EIGEN_CREATE);

    for (int i = 0; i < basis.numRows() - 1; i++) {
      Vector realEigen = new DenseVector(corpus.numCols());
      // the eigenvectors live as columns of V, in reverse order.  Weird but true.
      DoubleMatrix1D ejCol = eigenVects.viewColumn(basis.numRows() - i - 1);
      for (int j = 0; j < ejCol.size(); j++) {
        double d = ejCol.getQuick(j);
        realEigen.assign(basis.getRow(j), new PlusMult(d));
      }
      realEigen = realEigen.normalize();
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    // which specifically details the case of covariance matrix inversion
    // Complexity: O(min(nm2,mn2))
    SingularValueDecomposition svd = new SingularValueDecomposition(m);
    Matrix sInv = svd.getS();
    // Inverse Diagonal Elems
    for (int i = 0; i < sInv.numRows(); i++) {
      double diagElem = sInv.get(i,i);
      if (diagElem > 0.0) {
        sInv.set(i, i, 1 / diagElem);
      } else {
        throw new IllegalStateException("Eigen Value equals to 0 found.");
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, svdData, IntWritable.class, VectorWritable.class);
    try {
      IntWritable key = new IntWritable();
      VectorWritable value = new VectorWritable();

      for (int row = 0; row < sData.numRows(); row++) {
        key.set(row);
        value.set(sData.getRow(row));
        writer.append(key, value);
      }
    } finally {
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

        new SequenceFileValueIterator<MatrixWritable>(inputPath, true, new Configuration());
    Matrix m = it.next().get();
    it.close();
    PrintStream ps = getPrintStream(outputFile);
    String[] columnLabels = getLabels(m.numCols(), m.getColumnLabelBindings(), "col");
    String[] rowLabels = getLabels(m.numRows(), m.getRowLabelBindings(), "row");
    if (doLabels) {
      ps.print("rowid,");
      ps.print(columnLabels[0]);
      for(int c = 1; c < m.numCols(); c++) {
        ps.print(',' + columnLabels[c]);
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

      for(int c = 1; c < m.numCols(); c++) {
        ps.print(',' + columnLabels[c]);
      }
      ps.println();
    }
    for(int r = 0; r < m.numRows(); r++) {
      if (doLabels) {
        ps.print(rowLabels[0] + ',');
      }
      ps.print(Double.toString(m.getQuick(r,0)));
      for(int c = 1; c < m.numCols(); c++) {
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    // which specifically details the case of covariance matrix inversion
    // Complexity: O(min(nm2,mn2))
    SingularValueDecomposition svd = new SingularValueDecomposition(m);
    Matrix sInv = svd.getS();
    // Inverse Diagonal Elems
    for (int i = 0; i < sInv.numRows(); i++) {
      double diagElem = sInv.get(i, i);
      if (diagElem > 0.0) {
        sInv.set(i, i, 1 / diagElem);
      } else {
        throw new IllegalStateException("Eigen Value equals to 0 found.");
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    Matrix similarityMatrix = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "part-r-00000"), 3, 3);

    assertNotNull(similarityMatrix);
    assertEquals(3, similarityMatrix.numCols());
    assertEquals(3, similarityMatrix.numRows());

    assertEquals(1.0, similarityMatrix.get(0, 0), EPSILON);
    assertEquals(1.0, similarityMatrix.get(1, 1), EPSILON);
    assertEquals(1.0, similarityMatrix.get(2, 2), EPSILON);
    assertEquals(0.0, similarityMatrix.get(2, 0), EPSILON);
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    Matrix similarityMatrix = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "part-r-00000"), 3, 3);

    assertNotNull(similarityMatrix);
    assertEquals(3, similarityMatrix.numCols());
    assertEquals(3, similarityMatrix.numRows());

    assertEquals(0.0, similarityMatrix.get(0, 0), EPSILON);
    assertEquals(0.5, similarityMatrix.get(0, 1), EPSILON);
    assertEquals(0.0, similarityMatrix.get(0, 2), EPSILON);
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    Matrix similarityMatrix = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "part-r-00000"), 3, 3);

    assertNotNull(similarityMatrix);
    assertEquals(3, similarityMatrix.numCols());
    assertEquals(3, similarityMatrix.numRows());

    assertEquals(0.0, similarityMatrix.get(0, 0), EPSILON);
    assertEquals(0.5, similarityMatrix.get(0, 1), EPSILON);
    assertEquals(0.0, similarityMatrix.get(0, 2), EPSILON);
View Full Code Here

Examples of org.apache.mahout.math.Matrix.numRows()

    for(int row = 0; row < eigenVectors.numRows(); row++) {
      Vector oldEigen = eigenVectors.viewRow(row);
      if(oldEigen == null) {
        break;
      }
      for(int newRow = 0; newRow < eigenVectors2.numRows(); newRow++) {
        Vector newEigen = eigenVectors2.viewRow(newRow);
        if(newEigen != null) {
          if(oldEigen.dot(newEigen) > 0.9) {
            oldEigensFound.add(row);
            break;
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.