Package org.apache.mahout.math

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


          SequenceFile.createWriter(fs, conf, tempSequenceFile,
              IntWritable.class, VectorWritable.class);
      for (int i = 0; i < testPoints; i++) {
        key.set(i);
        Vector v = new SequentialAccessSparseVector(4);
        v.assign(i);
        value.set(v);
        writer.append(key, value);
      }
    } finally {
      IOUtils.closeStream(writer);
View Full Code Here


 
  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new SequentialAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

  @Test
  public void testClusterAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertTrue(formatString.contains("\"r\":[]"));
    assertTrue(formatString.contains("\"c\":[{\"0\":1.1},{\"2\":3.3}]"));
    assertTrue(formatString.contains("\"n\":0"));
View Full Code Here

  @Test
  public void testClusterAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertTrue(formatString.contains("\"r\":[]"));
    assertTrue(formatString.contains("\"c\":[{\"0\":1.1},{\"2\":3.3}]"));
    assertTrue(formatString.contains("\"n\":0"));
View Full Code Here

 
  public static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new SequentialAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
 
View Full Code Here

    try {
      writer = SequenceFile.createWriter(fs, conf, tempSequenceFile, IntWritable.class, VectorWritable.class);
      for (int i = 0; i < testPoints; i++) {
        key.set(i);
        Vector v = new SequentialAccessSparseVector(4);
        v.assign(i);
        value.set(v);
        writer.append(key, value);
      }
    } finally {
      IOUtils.closeStream(writer);
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.