Package org.apache.mahout.math

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


    Matrix input = data_set.getFirst();
    Matrix labels = data_set.getSecond();
   
    System.out.println( "Beginning LogReg Training on CovType");
   
    LogisticRegression logRegression = new LogisticRegression( input, input.numCols(), labels.numCols());

    double learningRate = 0.001;
   
    for (int i = 0; i < 1000; i++) {
     
View Full Code Here


   
    Matrix res = new DenseMatrix( rows, cols );
   
    for ( int r = 0; r < res.numRows(); r++ ) {
     
      for ( int c = 0; c < res.numCols(); c++ ) {
       
        res.set(r,  c, rnd.nextDouble());
        //System.out.println( "next: " + rnd.nextDouble() );
       
      }
View Full Code Here

   
    Matrix res = new DenseMatrix( rows, cols );
   
    for ( int r = 0; r < res.numRows(); r++ ) {
     
      for ( int c = 0; c < res.numCols(); c++ ) {
       
        res.set(r,  c, rnd.nextDouble());
        //System.out.println( "next: " + rnd.nextDouble() );
       
      }
View Full Code Here

    Matrix input = data_set.getFirst();
    Matrix labels = data_set.getSecond();
   
    System.out.println( "Beginning LogReg Training on CovType");
   
    LogisticRegression logRegression = new LogisticRegression( input, input.numCols(), labels.numCols());

    double learningRate = 0.001;
    logRegression.labels = labels;
   
    LogisticRegressionOptimizer opt = new LogisticRegressionOptimizer( logRegression, learningRate );
View Full Code Here

    m.setQuick(1, 2, 0);

    Matrix result = MatrixUtils.unroll(m);
   
    assertEquals(1, result.numRows());
    assertEquals(6, result.numCols());
   
    assertEquals( 6.0, result.get(0, 0), 0.0 );
    assertEquals( 5.0, result.get(0, 3), 0.0 );
    assertEquals( 0.0, result.get(0, 5), 0.0 );
   
View Full Code Here

    Matrix label = new DenseMatrix( 1, v_out.size() );
    label.viewRow(0).assign(v_out);
   
    boolean found = false;
   
    for (int col = 0; col < label.numCols(); col++) {
     
      if (label.get(0, col) > 0) {
        found = true;
        break;
      }
View Full Code Here

  public static Matrix genBinomialDistribution(Matrix pValues, int max, RandomGenerator rndNumberGenerator) {

    Matrix dist = pValues.like();

    for (int r = 0; r < dist.numRows(); r++) {
      for ( int c = 0; c < dist.numCols(); c++ ) {

        dist.set(r, c, getBinomial(rndNumberGenerator, max, pValues.get(r,  c) ) );

      }
    }
View Full Code Here

      man.setCurrent(cursor);
      //note data normalization
      try {
        Matrix in = MatrixUtils.toMatrix(ArrayUtils.flatten(man.readImage()));
       
        for (int d = 0; d < in.numCols(); d++) {
         
          if (in.get(0, d) > 30) {
           
            in.set(0, d, 1);
           
View Full Code Here


        Matrix out = createOutputVector(man.readLabel());
        boolean found = false;
       
        for (int col = 0; col < out.numCols(); col++) {
         
          if (out.get(0, col) > 0) {
            found = true;
            break;
          }
View Full Code Here

    m.setQuick(1, 2, 0);
   
   
    Matrix row_means_matrix = MatrixUtils.rowMeans(m); //m.rowMeans();
   
    assertEquals(1, row_means_matrix.numCols() );
    assertEquals(m.numRows(), row_means_matrix.numRows() );
   
    assertEquals( 6.0, row_means_matrix.get(0, 0), 0.0);
    assertEquals( 5.0, row_means_matrix.get(1, 0), 0.0);
   
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.