Package org.apache.mahout.math

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


      Matrix aI = m.get();
      Matrix omega = new RandomTrinaryMatrix(seed, aI.columnSize(), internalDimension, false);
      Matrix y = aI.times(omega);

      if (y2 == null) {
        y2 = y.transpose().times(y);
      } else {
        y2.assign(y.transpose().times(y), Functions.PLUS);
      }
    }
    r2 = new CholeskyDecomposition(y2);
View Full Code Here


      Matrix y = aI.times(omega);

      if (y2 == null) {
        y2 = y.transpose().times(y);
      } else {
        y2.assign(y.transpose().times(y), Functions.PLUS);
      }
    }
    r2 = new CholeskyDecomposition(y2);

    // step 2, compute B
View Full Code Here

        Vector sq = SSVDHelper.loadAndSumUpVectors(sqPath, conf);
        Vector sb = SSVDHelper.loadAndSumUpVectors(sbPath, conf);
        Matrix mC = sq.cross(sb);

        bbtSquare.assign(mC, Functions.MINUS);
        bbtSquare.assign(mC.transpose(), Functions.MINUS);
        mC = null;

        Matrix outerSq = sq.cross(sq);
        outerSq.assign(Functions.mult(xisquaredlen));
        bbtSquare.assign(outerSq, Functions.PLUS);
View Full Code Here

   * @param recomputeUserFeatures
   */
  public void reCalculateTrans(boolean recomputeUserFeatures) {
    if (!recomputeUserFeatures) {
      Matrix uMatrix = new DenseMatrix(userMatrix);
      userTransUser = uMatrix.transpose().times(uMatrix);
    } else {
      Matrix iMatrix = new DenseMatrix(itemMatrix);
      itemTransItem = iMatrix.transpose().times(iMatrix);
    }
  }
View Full Code Here

    if (!recomputeUserFeatures) {
      Matrix uMatrix = new DenseMatrix(userMatrix);
      userTransUser = uMatrix.transpose().times(uMatrix);
    } else {
      Matrix iMatrix = new DenseMatrix(itemMatrix);
      itemTransItem = iMatrix.transpose().times(iMatrix);
    }
  }

  private synchronized void updateMatrix(int id, Matrix m) {
    double normA = 0;
View Full Code Here

      if (recomputeUserFeatures) {
        Matrix I = identityV(dataModel.getNumItems());
        Matrix I2 = identityV(numFeatures);
        Matrix iTi = itemTransItem.clone();
        Matrix itemM = new DenseMatrix(itemMatrix);
        XTCX = iTi.plus(itemM.transpose().times(C.minus(I)).times(itemM));

        Matrix diag = solve(XTCX.plus(I2.times(preventOverfitting)), I2);
        Matrix results = diag.times(itemM.transpose().times(C)).times(prefVector.transpose());
        updateMatrix(id, results);
      } else {
View Full Code Here

      } else {
        Matrix I = identityV(dataModel.getNumUsers());
        Matrix I2 = identityV(numFeatures);
        Matrix uTu = userTransUser.clone();
        Matrix userM = new DenseMatrix(userMatrix);
        XTCX = uTu.plus(userM.transpose().times(C.minus(I)).times(userM));

        Matrix diag = solve(XTCX.plus(I2.times(preventOverfitting)), I2);
        Matrix results = diag.times(userM.transpose().times(C)).times(prefVector.transpose());
        updateMatrix(id, results);
      }
View Full Code Here

    int row = 0;
    for (int index : indexes.elements()) {
      compactedY.assignRow(row++, Y.get(index));
    }

    return compactedY.transpose().times(compactedY);
  }

  /** Y' (Cu - I) Y + λ I */
  private Matrix YtransponseCuMinusIYPlusLambdaI(Vector userRatings) {
    Preconditions.checkArgument(userRatings.isSequentialAccess(), "need sequential access to ratings!");
View Full Code Here

        return fileName.matches("V-.*");
      }
    })));

    // The values in A are pretty big so this is a pretty tight relative tolerance
    assertEquals(0, A.minus(u.times(new DiagonalMatrix(s.getSingularValues())).times(v.transpose())).aggregate(Functions.PLUS, Functions.ABS), 1.0e-7);
  }

  /**
   * Reads a list of files that contain a column of blocks.  It is assumed that the files
   * can be sorted lexicographically to determine the order they should be stacked.  It
View Full Code Here

      public double apply(double arg1) {
        return gen.nextGaussian();
      }
    });

    a = a.transpose().times(a);

    EigenDecomposition eig = new EigenDecomposition(a);
    Matrix d = eig.getD();
    Matrix v = eig.getV();
    check("EigenvalueDecomposition (rank deficient)...", a.times(v), v.times(d));
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.