Examples of viewRow()


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

          topicTermCounts.viewRow(x).set(term, random.nextDouble());
        }
      }
    }
    for(int x = 0; x < numTopics; x++) {
      topicSums.set(x, random == null ? 1.0 : topicTermCounts.viewRow(x).norm(1));
    }
    return Pair.of(topicTermCounts, topicSums);
  }

  public static Pair<Matrix, Vector> loadModel(Configuration conf, Path... modelPaths)
View Full Code Here

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

      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

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

      IntWritable key = new IntWritable();
      VectorWritable value = new VectorWritable();
     
      for (int row = 0; row < sData.numRows(); row++) {
        key.set(row);
        value.set(sData.viewRow(row));
        writer.append(key, value);
      }
    } finally {
      Closeables.closeQuietly(writer);
    }
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.Matrix.viewRow()

   *         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.getRow(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()

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

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

    Matrix topicTermCounts = new DenseMatrix(numTopics, numTerms);
    Vector topicSums = new DenseVector(numTopics);
    if (random != null) {
      for (int x = 0; x < numTopics; x++) {
        for (int term = 0; term < numTerms; term++) {
          topicTermCounts.viewRow(x).set(term, random.nextDouble());
        }
      }
    }
    for (int x = 0; x < numTopics; x++) {
      topicSums.set(x, random == null ? 1.0 : topicTermCounts.viewRow(x).norm(1));
View Full Code Here

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

          topicTermCounts.viewRow(x).set(term, random.nextDouble());
        }
      }
    }
    for (int x = 0; x < numTopics; x++) {
      topicSums.set(x, random == null ? 1.0 : topicTermCounts.viewRow(x).norm(1));
    }
    return Pair.of(topicTermCounts, topicSums);
  }

  public static Pair<Matrix, Vector> loadModel(Configuration conf, Path... modelPaths)
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.