Package org.apache.mahout.math

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


    // fetch the alpha matrix using the forward algorithm
    Matrix alpha = HmmAlgorithms.forwardAlgorithm(getModel(), getSequence(), false);
    // first do some basic checking
    assertNotNull(alpha);
    assertEquals(4, alpha.numCols());
    assertEquals(7, alpha.numRows());
    // now compare the resulting matrices
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 7; ++j) {
        assertEquals(alphaExpectedA[i][j], alpha.get(j, i), EPSILON);
      }
View Full Code Here

    // fetch the alpha matrix using the forward algorithm
    Matrix alpha = HmmAlgorithms.forwardAlgorithm(getModel(), getSequence(), true);
    // first do some basic checking
    assertNotNull(alpha);
    assertEquals(4, alpha.numCols());
    assertEquals(7, alpha.numRows());
    // now compare the resulting matrices
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 7; ++j) {
        assertEquals(Math.log(alphaExpectedA[i][j]), alpha.get(j, i), EPSILON);
      }
View Full Code Here

    // fetch the beta matrix using the backward algorithm
    Matrix beta = HmmAlgorithms.backwardAlgorithm(getModel(), getSequence(), false);
    // first do some basic checking
    assertNotNull(beta);
    assertEquals(4, beta.numCols());
    assertEquals(7, beta.numRows());
    // now compare the resulting matrices
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 7; ++j) {
        assertEquals(betaExpectedA[i][j], beta.get(j, i), EPSILON);
      }
View Full Code Here

    // fetch the beta matrix using the backward algorithm
    Matrix beta = HmmAlgorithms.backwardAlgorithm(getModel(), getSequence(), true);
    // first do some basic checking
    assertNotNull(beta);
    assertEquals(4, beta.numCols());
    assertEquals(7, beta.numRows());
    // now compare the resulting matrices
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 7; ++j) {
        assertEquals(Math.log(betaExpectedA[i][j]), beta.get(j, i), EPSILON);
      }
View Full Code Here

    DistributedRowMatrix dm =
        randomDistributedMatrix(100, 90, 50, 20, 1.0, false);
    dm.setConf(getConfiguration());

    Vector expected = new DenseVector(50);
    for (int i = 0; i < m.numRows(); i++) {
      expected.assign(m.viewRow(i), Functions.PLUS);
    }
    expected.assign(Functions.DIV, m.numRows());
    Vector actual = dm.columnMeans("DenseVector");
    assertEquals(0.0, expected.getDistanceSquared(actual), EPSILON);
View Full Code Here

    Vector expected = new DenseVector(50);
    for (int i = 0; i < m.numRows(); i++) {
      expected.assign(m.viewRow(i), Functions.PLUS);
    }
    expected.assign(Functions.DIV, m.numRows());
    Vector actual = dm.columnMeans("DenseVector");
    assertEquals(0.0, expected.getDistanceSquared(actual), EPSILON);
  }

  @Test
View Full Code Here

    DistributedRowMatrix dm =
        randomDistributedMatrix(100, 90, 0, 0, 1.0, false);
    dm.setConf(getConfiguration());

    Vector expected = new DenseVector(0);
    for (int i = 0; i < m.numRows(); i++) {
      expected.assign(m.viewRow(i), Functions.PLUS);
    }
    expected.assign(Functions.DIV, m.numRows());
    Vector actual = dm.columnMeans();
    assertEquals(0.0, expected.getDistanceSquared(actual), EPSILON);
View Full Code Here

    Vector expected = new DenseVector(0);
    for (int i = 0; i < m.numRows(); i++) {
      expected.assign(m.viewRow(i), Functions.PLUS);
    }
    expected.assign(Functions.DIV, m.numRows());
    Vector actual = dm.columnMeans();
    assertEquals(0.0, expected.getDistanceSquared(actual), EPSILON);
  }

  @Test
View Full Code Here

    Pair<List<List<WeightedThing<Vector>>>, Long> reference = getResultsAndRuntime(bruteSearcher, queries);

    Pair<List<WeightedThing<Vector>>, Long> referenceSearchFirst =
        getResultsAndRuntimeSearchFirst(bruteSearcher, queries);

    double bruteSearchAvgTime = reference.getSecond() / (queries.numRows() * 1.0);
    System.out.printf("BruteSearch: avg_time(1 query) %f[s]\n", bruteSearchAvgTime);

    return Arrays.asList(new Object[][]{
        // NUM_PROJECTIONS = 3
        // SEARCH_SIZE = 10
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.