Package org.apache.mahout.math

Examples of org.apache.mahout.math.Vector.dot()


    userIDs = dataModel.getUserIDs();
    while (userIDs.hasNext()) {
      long userID = userIDs.nextLong();
      Vector userVector = new DenseVector(factorization.getUserFeatures(userID));
      double regularization = userVector.dot(userVector);
      sum += regularization;
    }

    itemIDs = dataModel.getItemIDs();
    while (itemIDs.hasNext()) {
View Full Code Here


    itemIDs = dataModel.getItemIDs();
    while (itemIDs.hasNext()) {
      long itemID = itemIDs.nextLong();
      Vector itemVector = new DenseVector(factorization.getUserFeatures(itemID));
      double regularization = itemVector.dot(itemVector);
      sum += regularization;
    }

    double rmse = Math.sqrt(avg.getAverage());
    double loss = avg.getAverage() / 2 + lambda / 2 * sum;
 
View Full Code Here

    userIDs = dataModel.getUserIDs();
    while (userIDs.hasNext()) {
      long userID = userIDs.nextLong();
      Vector userVector = new DenseVector(factorization.getUserFeatures(userID));
      double regularization=userVector.dot(userVector);
      sum += regularization;
    }

    itemIDs = dataModel.getItemIDs();
    while (itemIDs.hasNext()) {
View Full Code Here

    itemIDs = dataModel.getItemIDs();
    while (itemIDs.hasNext()) {
      long itemID = itemIDs.nextLong();
      Vector itemVector = new DenseVector(factorization.getUserFeatures(itemID));
      double regularization = itemVector.dot(itemVector);
      sum += regularization;
    }

    double rmse = Math.sqrt(avg.getAverage());
    double loss = avg.getAverage() / 2 + lambda / 2 * sum;
 
View Full Code Here

    w.addToVector("and", v3);
    w.addToVector("more", v3);
    assertEquals(0, v3.minus(v2).norm(1), 0);

    // moreover, the locations set in the unweighted case should be the same as in the weighted case
    assertEquals(v3.zSum(), v3.dot(v1), 0);
  }

  @Test
  public void testAsString() {
    Locale.setDefault(Locale.ENGLISH);
View Full Code Here

        plusMult.setMultiplicator(-xii);
        bCol.assign(sq, plusMult);
      }

      for (int i = 0; i < k; i++) {
        vRow.setQuick(i, bCol.dot(uHat.viewColumn(i)) / sValues.getQuick(i));
      }
      context.write(key, vRowWritable);
    }

    @Override
View Full Code Here

    for (int c = 0; c < n; c++) {
      Vector col = mx.viewColumn(c);
      for (int c1 = 0; c1 < c; c1++) {
        Vector viewC1 = mx.viewColumn(c1);
        col.assign(col.minus(viewC1.times(viewC1.dot(col))));

      }
      final double norm2 = col.norm(2);
      col.assign(new DoubleFunction() {
        @Override
View Full Code Here

         * multiple task output that we assume we need to sum up partial
         * components. If it is just one file, it will work too.
         */

        Vector xi = SSVDHelper.loadAndSumUpVectors(pcaMeanPath, conf);
        xisquaredlen = xi.dot(xi);
        Omega omega = new Omega(seed, k + p);
        Vector s_b0 = omega.mutlithreadedTRightMultiply(xi);

        SSVDHelper.saveVector(s_b0, sbPath =
          new Path(pcaBasePath, "somega.seq"), conf);
View Full Code Here

      throws IOException, InterruptedException {
      Vector qRow = value.get();
      if (sValues != null) {
        for (int i = 0; i < k; i++) {
          uRow.setQuick(i,
                        qRow.dot(uHat.viewColumn(i)) * sValues.getQuick(i));
        }
      } else {
        for (int i = 0; i < k; i++) {
          uRow.setQuick(i, qRow.dot(uHat.viewColumn(i)));
        }
View Full Code Here

          uRow.setQuick(i,
                        qRow.dot(uHat.viewColumn(i)) * sValues.getQuick(i));
        }
      } else {
        for (int i = 0; i < k; i++) {
          uRow.setQuick(i, qRow.dot(uHat.viewColumn(i)));
        }
      }

      context.write(key, uRowWritable); // U inherits original A row labels.
    }
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.