Package org.apache.mahout.math

Examples of org.apache.mahout.math.CardinalityException


public class MyDistanceMeasure implements DistanceMeasure {
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    double lengthSquaredv1 = v1.getLengthSquared();
    double lengthSquaredv2 = v2.getLengthSquared();
   
    double dotProduct = v2.dot(v1);
View Full Code Here


  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException();
    }
    double lengthSquaredv1 = v1.getLengthSquared();
    double lengthSquaredv2 = v2.getLengthSquared();
   
    double dotProduct = v2.dot(v1);
View Full Code Here

   * */
  public void train(Vector labelset, Matrix dataset) throws IndexException,
                                                    CardinalityException,
                                                    TrainingException {
    if (labelset.size() != dataset.size()[1]) {
      throw new CardinalityException();
    }
   
    boolean converged = false;
    int iteration = 0;
    while (!converged) {
View Full Code Here

  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException();
    }
    double result = 0;
    Vector vector = v1.minus(v2);
    Iterator<Vector.Element> iter = vector.iterateNonZero();
    // this contains all non zero elements between the two
View Full Code Here

    return numCols;
  }

  public DistributedRowMatrix times(DistributedRowMatrix other) {
    if(numRows != other.numRows()) {
      throw new CardinalityException(numRows, other.numRows());
    }
    Path outPath = new Path(outputTmpBasePath.getParent(), "productWith");
    JobConf conf = MatrixMultiplicationJob.createMatrixMultiplyJobConf(rowPath, other.rowPath, outPath, other.numCols);
    try {
      JobClient.runJob(conf);
View Full Code Here

  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    double lengthSquaredv1 = v1.getLengthSquared();
    double lengthSquaredv2 = v2.getLengthSquared();
   
    double dotProduct = v2.dot(v1);
View Full Code Here

  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    Preconditions.checkArgument(meanVector != null, "meanVector not initialized");
    Preconditions.checkArgument(inverseCovarianceMatrix != null, "inverseCovarianceMatrix not initialized");
   
    return Math.sqrt(v1.minus(v2).dot(Algebra.mult(inverseCovarianceMatrix, v1.minus(v2))));
View Full Code Here

   * @throws IllegalArgumentException
   *             if <tt>eigen values equal to 0 found</tt>.
   */
  public void setCovarianceMatrix(Matrix m) {   
    if (m.numRows() != m.numCols()) {
      throw new CardinalityException(m.numRows(), m.numCols());
    }
    // See http://www.mlahanas.de/Math/svd.htm for details,
    // which specifically details the case of covariance matrix inversion
    // Complexity: O(min(nm2,mn2))
    SingularValueDecomposition svd = new SingularValueDecomposition(m);
View Full Code Here

  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    double result = 0;
    Vector vector = v1.minus(v2);
    Iterator<Vector.Element> iter = vector.iterateNonZero();
    // this contains all non zero elements between the two
View Full Code Here

  }

  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    return Math.sqrt(v1.minus(v2).dot(Algebra.mult(inverseCovarianceMatrix, v1.minus(v2))));
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.CardinalityException

Copyright © 2018 www.massapicom. 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.