Examples of viewRow()


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

    }
    numTopics++;
    Matrix model = new DenseMatrix(numTopics, numTerms);
    Vector topicSums = new DenseVector(numTopics);
    for (Pair<Integer, Vector> pair : rows) {
      model.viewRow(pair.getFirst()).assign(pair.getSecond());
      topicSums.set(pair.getFirst(), pair.getSecond().norm(1));
    }
    return Pair.of(model, topicSums);
  }
View Full Code Here

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

          double f = ortPiece.dot(hessenBerg.viewColumn(j).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewColumn(j).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }

        for (int i = 0; i <= high; i++) {
          double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewRow(i).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }
        ort.setQuick(m, scale * ort.getQuick(m));
        hessenBerg.setQuick(m, m - 1, scale * g);
      }
View Full Code Here

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

          hessenBerg.viewColumn(j).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }

        for (int i = 0; i <= high; i++) {
          double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewRow(i).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }
        ort.setQuick(m, scale * ort.getQuick(m));
        hessenBerg.setQuick(m, m - 1, scale * g);
      }
    }
View Full Code Here

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

    // Put the centroids into a matrix.
    Matrix x = new DenseMatrix(6, 5);
    int row = 0;
    for (Centroid c : r) {
      x.viewRow(row).assign(c.viewPart(0, 5));
      row++;
    }

    // Verify that each column looks right. Should contain zeros except for a single 6.
    final Vector columnNorms = x.aggregateColumns(new VectorFunction() {
View Full Code Here

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

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

  /**
 
View Full Code Here

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

      .learningRate(5);
    int k = 0;
    int[] ordering = permute(gen, data.numRows());
    for (int epoch = 0; epoch < 100; epoch++) {
      for (int row : ordering) {
        lr.train(row, (int) data.get(row, 9), data.viewRow(row));
        System.out.printf("%d,%d,%.3f\n", epoch, k++, lr.auc());
      }
      assertEquals(1, lr.auc(), 0.2);
    }
    assertEquals(1, lr.auc(), 0.1);
View Full Code Here

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

      }
      int c = r.nextInt(numRows);
      if (r.nextBoolean() || numRows == nonNullRows) {
        m.assignRow(numRows == nonNullRows ? i : c, v);
      } else {
        Vector other = m.viewRow(r.nextInt(numRows));
        if (other != null && other.getLengthSquared() > 0) {
          m.assignRow(c, other.clone());
        }
      }
      //n += m.getRow(c).getLengthSquared();
View Full Code Here

Examples of org.apache.mahout.math.SparseRowMatrix.viewRow()

      }
      int c = r.nextInt(numRows);
      if (r.nextBoolean() || numRows == nonNullRows) {
        m.assignRow(numRows == nonNullRows ? i : c, v);
      } else {
        Vector other = m.viewRow(r.nextInt(numRows));
        if (other != null && other.getLengthSquared() > 0) {
          m.assignRow(c, other.clone());
        }
      }
      //n += m.getRow(c).getLengthSquared();
View Full Code Here

Examples of org.apache.mahout.math.matrix.DoubleMatrix2D.viewRow()

   *
   * @param matrix the matrix to convert.
   */
  public String toString(DoubleMatrix1D matrix) {
    DoubleMatrix2D easy = matrix.like2D(1, matrix.size());
    easy.viewRow(0).assign(matrix);
    return toString(easy);
  }

  /**
   * Returns a string representation of the given matrix.
View Full Code Here

Examples of org.apache.mahout.math.matrix.DoubleMatrix2D.viewRow()

    for (int r = rowIndexes.length; --r >= 0;) {
      int row = rowIndexes[r];
      if (row < 0 || row >= rows) {
        throw new IndexOutOfBoundsException("Illegal Index");
      }
      sub.viewRow(r).assign(A.viewRow(row));
    }
    return sub;
  }

  /**
 
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.