Examples of assign()


Examples of org.apache.mahout.math.DenseVector.assign()

   *          initial classification bias.
   * */
  protected LinearTrainer(int dimension, double threshold,
                          double init, double initBias) throws CardinalityException {
    DenseVector initialWeights = new DenseVector(dimension);
    initialWeights.assign(init);
    this.model = new LinearModel(initialWeights, initBias, threshold);
  }
 
  /**
   * Initializes training. Runs through all data points in the training set and
View Full Code Here

Examples of org.apache.mahout.math.DenseVector.assign()

   * @return
   */
  @Override
  protected Vector getInitialVector(VectorIterable corpus) {
    Vector initialVector = new DenseVector(corpus.numCols());
    initialVector.assign(1/Math.sqrt(corpus.numCols()));
    return initialVector;
  }

  @Override
  public int run(String[] strings) throws Exception {
View Full Code Here

Examples of org.apache.mahout.math.Matrix.assign()

  @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

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

    FeatureVectorEncoder encoder = new StaticWordValueEncoder("text");
    for (String word : doc.elementSet()) {
      encoder.addToVector(word, w.weight(word, doc.count(word)), v);
    }
    if (normalize) {
      return v.assign(Functions.div(v.norm(2)));
    } else {
      return v;
    }
  }
View Full Code Here

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

  public static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = new ArrayList<Vector>();
    for (int i = 0; i < raw.length; i++) {
      double[] fr = raw[i];
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = new ArrayList<VectorWritable>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

  private static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = new ArrayList<VectorWritable>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

  private static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = new ArrayList<Vector>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()

  private static List<VectorWritable> getPoints(double[][] raw) {
    List<VectorWritable> points = new ArrayList<VectorWritable>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.SequentialAccessSparseVector.assign()

  }

  public void testCanopyAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Printable cluster = new Canopy(m, 123);
    String formatString = cluster.asFormatString(null);
    System.out.println(formatString);
    assertEquals("format", "C123: [0:1.100, 2:3.300]", formatString);
  }
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.