Package org.apache.mahout.math

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


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

    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 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

    Matrix lastWeightMatrix = weightMatrixList.get(weightMatrixList.size() - 1);

    for (int i = 0; i < deltaVec.size(); ++i) {
      double costFuncDerivative = costFunction.apply(labels.get(i), output.get(i + 1));
      // Add regularization
      costFuncDerivative += regularizationWeight * lastWeightMatrix.viewRow(i).zSum();
      deltaVec.set(i, costFuncDerivative);
      deltaVec.set(i, deltaVec.get(i) * derivativeSquashingFunction.apply(output.get(i + 1)));
    }

    // Start from previous layer of output layer
View Full Code Here

    /* Y' (Cu -I) Y by outer products */
    for (Element e : userRatings.nonZeroes()) {
      for (Vector.Element feature : Y.get(e.index()).all()) {
        Vector partial = CuMinusIY.get(e.index()).times(feature.get());
        YtransponseCuMinusIY.viewRow(feature.index()).assign(partial, Functions.PLUS);
      }
    }

    /* Y' (Cu - I) Y + λ I  add lambda on the diagonal */
    for (int feature = 0; feature < numFeatures; feature++) {
View Full Code Here

        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

        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

      int rowLabel = labels.viewRow( row ).maxValueIndex();
     
      if ( filter.containsKey(rowLabel)) {
       
        inputFiltered.viewRow(recFound).assign( input.viewRow(row) );
        labelsFiltered.viewRow(recFound).assign( labels.viewRow(row) );
        recFound++;
       
        if ( recFound >= inputFiltered.numRows() ) {
          break;
        }
View Full Code Here

   
    MatrixUtils.debug_print( labels );
   
    MatrixUtils.debug_print_matrix_stats(labels, "lables");
   
    System.out.println( "label: " + labels.viewRow(0).maxValueIndex() );
   
   
  }
 
 
View Full Code Here

        //System.out.println("line: " + line);
        //System.out.println("v in: " + v_in_0.toString());
       
        input_matrix.viewRow( row_num ).assign( v_in_0 );
       
        output_matrix.viewRow( row_num ).assign( v_out_0 );
       
        row_num++;
       
      }
      br.close()
View Full Code Here

    // vector 0
    for ( int row = 0; row < v.numRows(); row++ ) {
   
      for ( int col = 0; col < v.numCols(); col++ ) {
     
        assertEquals( v.viewRow(row).get(col), recon.viewRow(row).get(col), 0.3 );
     
      }
     
    }
   
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.