Examples of assign()


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

  }

  public void testCanopyAsFormatStringSparseWithBindings() {
    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

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

  }

  public void testClusterAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Printable cluster = new Cluster(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

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

  }

  public void testClusterAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Printable cluster = new Cluster(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

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

  }

  public void testMSCanopyAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Printable cluster = new MeanShiftCanopy(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

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

  }

  public void testMSCanopyAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Printable cluster = new MeanShiftCanopy(m, 123);
    String[] bindings = { "fee", null, "foo" };
    String formatString = cluster.asFormatString(bindings);
    System.out.println(formatString);
    assertEquals("format", "C123: [fee:1.100, foo:3.300]", formatString);
View Full Code Here

Examples of org.apache.mahout.math.SequentialAccessSparseVector.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 SequentialAccessSparseVector(String.valueOf(i), fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
 
View Full Code Here

Examples of org.apache.mahout.math.Vector.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.Vector.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.Vector.assign()

    Vector v = new DenseVector(1000);
    ByteBuffer buf = ByteBuffer.wrap(FileUtils
        .readFileToByteArray(new File(args[1])));
    FastLine line = FastLine.read(buf);
    while (line != null) {
      v.assign(0);
      for (int i = 0; i < FIELDS; i++) {
        encoder[i].addToVector((byte[]) null, line.getDouble(i), v);
      }
      line = FastLine.read(buf);
    }
View Full Code Here

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

    long t0 = System.currentTimeMillis();
    Vector v = new DenseVector(1000);
    BufferedReader in = new BufferedReader(new FileReader(args[1]));
    String line = in.readLine();
    while (line != null) {
      v.assign(0);
      Line x = new Line(line);
      for (int i = 0; i < FIELDS; i++) {
        encoder[i].addToVector((byte[]) null, x.getDouble(i), v);
      }
      line = in.readLine();
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.