Package org.apache.mahout.math.function

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


        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
        public double apply(double x) {
          return x / norm2;
        }
      });
View Full Code Here


      // finish off pending regularization
      model.close();

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

    }
    return corpus;
  }

  public static Matrix randomStructuredModel(int numTopics, int numTerms) {
    return randomStructuredModel(numTopics, numTerms, new DoubleFunction() {
      @Override public double apply(double d) {
        return 1.0 / (1 + Math.abs(d));
      }
    });
  }
View Full Code Here

    final Random rand = RandomUtils.getRandom();

    // build a vector full of sample from exponential distribuiton
    // this will have lots of little positive values and a few big ones
    Vector p1 = new DenseVector(25)
      .assign(new DoubleFunction() {
        @Override
        public double apply(double arg1) {
          return -Math.log1p(-rand.nextDouble());
        }
      });
View Full Code Here

    return unpivot;
  }

  private static Vector randomVector() {
    Vector v = new DenseVector(20);
    v.assign(new DoubleFunction() {
      private final Random gen = RandomUtils.getRandom();

      @Override
      public double apply(double arg1) {
        return gen.nextDouble();
View Full Code Here

  public void test1() {

    final Random rand = RandomUtils.getRandom();

    Matrix z = new DenseMatrix(100, 100);
    z.assign(new DoubleFunction() {
      @Override
      public double apply(double arg1) {
        return rand.nextDouble();
      }
    });
View Full Code Here

  private static Matrix rank4Matrix() {
    final Random rand = RandomUtils.getRandom();

    Matrix u = new DenseMatrix(10, 4);
    u.assign(new DoubleFunction() {
      @Override
      public double apply(double arg1) {
        return rand.nextDouble();
      }
    });

    Matrix v = new DenseMatrix(10, 4);
    v.assign(new DoubleFunction() {
      @Override
      public double apply(double arg1) {
        return rand.nextDouble();
      }
    });
View Full Code Here

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

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

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

    }
  }

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

TOP

Related Classes of org.apache.mahout.math.function.DoubleFunction

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.