Package org.apache.mahout.math.hadoop.DistributedRowMatrix

Examples of org.apache.mahout.math.hadoop.DistributedRowMatrix.MatrixEntryWritable


      assertEquals("Should only be one vector", 1, list.size());
      // check that the elements in the array are correctly ordered
      Vector v = list.get(0).get();
      for (Vector.Element e : v) {
        // find this value in the original map
        MatrixEntryWritable toCompare = new MatrixEntryWritable();
        toCompare.setRow(-1);
        toCompare.setCol(e.index());
        toCompare.setVal(e.get());
        assertTrue("This entry was correctly placed in its row", map.get(row).contains(toCompare));
      }
    }
  }
View Full Code Here


      double similarityValue = similarity.similarity(rowA, rowB, cooccurrences, rowPair.getWeightA(),
          rowPair.getWeightB(), numberOfColumns);

      if (!Double.isNaN(similarityValue)) {
        SimilarityMatrixEntryKey key = new SimilarityMatrixEntryKey();
        MatrixEntryWritable entry = new MatrixEntryWritable();
        entry.setVal(similarityValue);

        entry.setRow(rowA);
        entry.setCol(rowB);
        key.set(rowA, similarityValue);
        ctx.write(key, entry);

        if (rowA != rowB) {
          entry.setRow(rowB);
          entry.setCol(rowA);
          key.set(rowB, similarityValue);
          ctx.write(key, entry);
        }
      }
    }
View Full Code Here

  public static MatrixEntryWritable matrixEntryMatches(final int row, final int col, final double value) {
    EasyMock.reportMatcher(new IArgumentMatcher() {
      @Override
      public boolean matches(Object argument) {
        if (argument instanceof MatrixEntryWritable) {
          MatrixEntryWritable entry = (MatrixEntryWritable) argument;
          return (row == entry.getRow()
              && col == entry.getCol()
              && Math.abs(value - entry.getVal()) <= MahoutTestCase.EPSILON);
        }
        return false;
      }

      @Override
View Full Code Here

  /**
   * convenience method to create a {@link MatrixEntryWritable}
   */
  public static MatrixEntryWritable matrixEntry(int row, int col, double value) {
    MatrixEntryWritable entry = new MatrixEntryWritable();
    entry.setRow(row);
    entry.setCol(col);
    entry.setVal(value);
    return entry;
  }
View Full Code Here

      assertEquals("Should only be one vector", 1, list.size());
      // check that the elements in the array are correctly ordered
      Vector v = list.get(0).get();
      for (Vector.Element e : v.all()) {
        // find this value in the original map
        MatrixEntryWritable toCompare = new MatrixEntryWritable();
        toCompare.setRow(-1);
        toCompare.setCol(e.index());
        toCompare.setVal(e.get());
        assertTrue("This entry was correctly placed in its row", map.get(row).contains(toCompare));
      }
    }
  }
View Full Code Here

  public static MatrixEntryWritable matrixEntryMatches(final int row, final int col, final double value) {
    EasyMock.reportMatcher(new IArgumentMatcher() {
      @Override
      public boolean matches(Object argument) {
        if (argument instanceof MatrixEntryWritable) {
          MatrixEntryWritable entry = (MatrixEntryWritable) argument;
          return (row == entry.getRow()
              && col == entry.getCol()
              && Math.abs(value - entry.getVal()) <= MahoutTestCase.EPSILON);
        }
        return false;
      }

      @Override
View Full Code Here

  /**
   * convenience method to create a {@link MatrixEntryWritable}
   */
  public static MatrixEntryWritable matrixEntry(int row, int col, double value) {
    MatrixEntryWritable entry = new MatrixEntryWritable();
    entry.setRow(row);
    entry.setCol(col);
    entry.setVal(value);
    return entry;
  }
View Full Code Here

      assertEquals("Should only be one vector", 1, list.size());
      // check that the elements in the array are correctly ordered
      Vector v = list.get(0).get();
      for (Vector.Element e : v.all()) {
        // find this value in the original map
        MatrixEntryWritable toCompare = new MatrixEntryWritable();
        toCompare.setRow(-1);
        toCompare.setCol(e.index());
        toCompare.setVal(e.get());
        assertTrue("This entry was correctly placed in its row", map.get(row).contains(toCompare));
      }
    }
  }
View Full Code Here

  public static MatrixEntryWritable matrixEntryMatches(final int row, final int col, final double value) {
    EasyMock.reportMatcher(new IArgumentMatcher() {
      @Override
      public boolean matches(Object argument) {
        if (argument instanceof MatrixEntryWritable) {
          MatrixEntryWritable entry = (MatrixEntryWritable) argument;
          return row == entry.getRow()
              && col == entry.getCol()
              && Math.abs(value - entry.getVal()) <= MahoutTestCase.EPSILON;
        }
        return false;
      }

      @Override
View Full Code Here

  /**
   * convenience method to create a {@link MatrixEntryWritable}
   */
  public static MatrixEntryWritable matrixEntry(int row, int col, double value) {
    MatrixEntryWritable entry = new MatrixEntryWritable();
    entry.setRow(row);
    entry.setCol(col);
    entry.setVal(value);
    return entry;
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.hadoop.DistributedRowMatrix.MatrixEntryWritable

Copyright © 2018 www.massapicom. 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.