Package org.apache.mahout.math.function

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


        // 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


  private int numDimensions;
  private int numProjections;
  private boolean initialized = false;

  static List<Vector> generateBasis(int numDimensions, int numProjections) {
    final DoubleFunction random = Functions.random();
    List<Vector> basisVectors = Lists.newArrayList();
    for (int i = 0; i < numProjections; ++i) {
      Vector basisVector = new DenseVector(numDimensions);
      basisVector.assign(random);
      basisVector.normalize();
View Full Code Here

    for(int i=0; i<terms.length; i++) {
      terms[i] = String.valueOf((char) (i + 'a'));
    }
    int numGeneratingTopics = 3;
    int numTerms = 26;
    Matrix matrix = ClusteringTestUtils.randomStructuredModel(numGeneratingTopics, numTerms, new DoubleFunction() {
      @Override public double apply(double d) {
        return 1.0 / Math.pow(d + 1.0, 2);
      }
    });
View Full Code Here

  @Test
  public void testRandomStructuredModelViaMR() throws Exception {
    int numGeneratingTopics = 3;
    int numTerms = 9;
    Matrix matrix = ClusteringTestUtils.randomStructuredModel(numGeneratingTopics, numTerms, new DoubleFunction() {
      @Override
      public double apply(double d) {
        return 1.0 / Math.pow(d + 1.0, 3);
      }
    });
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

  @Ignore("MAHOUT-399")
  public void testEndToEnd() throws Exception {
    int numGeneratingTopics = 5;
    int numTerms = 26;
    Matrix matrix = ClusteringTestUtils.randomStructuredModel(numGeneratingTopics, numTerms,
                                                              new DoubleFunction() {
                                                                @Override
                                                                public double apply(double d) {
                                                                  return 1.0 / Math.pow(d + 1, 3);
                                                                }
                                                              });
View Full Code Here

  @Test
  public void testGivensQR() throws Exception {
    // DenseMatrix m = new DenseMatrix(dims<<2,dims);
    Matrix m = new DenseMatrix(3, 3);
    m.assign(new DoubleFunction() {
      private final Random rnd = RandomUtils.getRandom();
      @Override
      public double apply(double arg0) {
        return rnd.nextDouble() * SCALE;
      }
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

          private final Random random = RandomUtils.getRandom();
          @Override
          public Vector apply(Integer dummy) {
            Vector result =
                type == VectorType.SPARSE ? new RandomAccessSparseVector(numItems) : new DenseVector(numItems);
            result.assign(new DoubleFunction(){
              @Override
              public double apply(double ignored) {
                return random.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

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.