Package org.apache.mahout.math.function

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


    }
    return new DenseMatrix(data);
  }

  private void normalize(Matrix source, final double range) {
    final double max = source.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector column) {
        return column.maxValue();
      }
    }).maxValue();

    final double min = source.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector column) {
        return column.minValue();
      }
    }).minValue();
View Full Code Here


      x.viewRow(row).assign(c.viewPart(0, 5));
      row++;
    }

    // Verify that each column looks right. Should contain zeros except for a single 6.
    final Vector columnNorms = x.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector f) {
        // Return the sum of three discrepancy measures.
        return Math.abs(f.minValue()) + Math.abs(f.maxValue() - 6) + Math.abs(f.norm(1) - 6);
      }
View Full Code Here

    }
  }

  @Test
  public void testAggregateRows() {
    Vector v = test.aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    });
View Full Code Here

    }
  }

  @Test
  public void testAggregateCols() {
    Vector v = test.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    });
View Full Code Here

  }

  @Test
  public void testAggregate() {
    double total = test.aggregate(Functions.PLUS, Functions.IDENTITY);
    assertEquals(test.aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    }).zSum(), total, EPSILON);
View Full Code Here

   * @param mapper   A function to apply to each element.
   * @return The result.
   */
  @Override
  public double aggregate(final DoubleDoubleFunction combiner, final DoubleFunction mapper) {
    return aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.aggregate(combiner, mapper);
      }
    }).aggregate(combiner, Functions.IDENTITY);
View Full Code Here

        final Vector pi = sampleNoLink();
        return pi.maxValueIndex();
    }

    private Vector sampleNoLink() {
        final Vector theta = state.aggregateRows(new VectorFunction() {
            final DoubleFunction inverseLink = new InverseLogisticFunction();

            @Override
            public double apply(Vector f) {
                return inverseLink.apply(rand.nextDouble(f.get(0), f.get(1)));
View Full Code Here

TOP

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

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.