Examples of UnaryFunction


Examples of org.apache.mahout.math.function.UnaryFunction

    public Vector next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      Vector result = type == VectorType.SPARSE ? new RandomAccessSparseVector(numItems) : new DenseVector(numItems);
      result.assign(new UnaryFunction(){
        @Override
        public double apply(double arg1) {
          return random.nextDouble();
        }
      });
View Full Code Here

Examples of org.apache.mahout.math.function.UnaryFunction

    public Vector next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      Vector result = type == VectorType.SPARSE ? new RandomAccessSparseVector(numItems) : new DenseVector(numItems);
      result.assign(new UnaryFunction(){
        @Override
        public double apply(double arg1) {
          return random.nextDouble();
        }
      });
View Full Code Here

Examples of org.apache.mahout.math.function.UnaryFunction

        // finish off pending regularization
        model.close();
       
        Matrix beta = model.getBeta();
        maxBeta = beta.aggregate(Functions.MAX, Functions.ABS);
        nonZeros = beta.aggregate(Functions.PLUS, new UnaryFunction() {
          @Override
          public double apply(double v) {
            return Math.abs(v) > 1.0e-6 ? 1 : 0;
          }
        });
        positive = beta.aggregate(Functions.PLUS, new UnaryFunction() {
          @Override
          public double apply(double v) {
            return v > 0 ? 1 : 0;
          }
        });
View Full Code Here

Examples of org.apache.mahout.math.function.UnaryFunction

    }
  }

  private static Vector randomVector(final Random gen, int n) {
    Vector x = new DenseVector(n);
    x.assign(new UnaryFunction() {
      @Override
      public double apply(double v) {
        return gen.nextGaussian();
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.UnaryFunction

    updateSteps.assign(other.updateSteps);
    updateCounts.assign(other.updateCounts);
  }

  public boolean validModel() {
    double k = beta.aggregate(Functions.PLUS, new UnaryFunction() {
      @Override
      public double apply(double v) {
        return Double.isNaN(v) || Double.isInfinite(v) ? 1 : 0;
      }
    });
View Full Code Here

Examples of org.apache.mahout.matrix.UnaryFunction

    public Vector next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      Vector result = type == VectorType.SPARSE ? new SparseVector(numItems) : new DenseVector(numItems);
      result.assign(new UnaryFunction(){
        @Override
        public double apply(double arg1) {
          return random.nextDouble();
        }
      });
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.