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

  double[] values = new double[CARDINALITY];
  values[3488] = 1.30227;
  values[4417] = 2.51266;
  values[4418] = 2.60221;
  Vector delegate = new SequentialAccessSparseVector(CARDINALITY);
  delegate.assign(values);
  return new NamedVector(delegate, DOCUMENT_LABEL);
    }

    @Test
    public void givenOneVectorshouldCallContextWriteOnce() throws IOException, InterruptedException {
View Full Code Here

        values[480] = 0.38624;
        values[1474] = 0.03848;
        values[570] = 0.74978;
        values[3281] = 1.11081;
        Vector delegate = new SequentialAccessSparseVector(CARDINALITY);
        delegate.assign(values);
        return new NamedVector(delegate, DOC_LABEL);
    }

    @Before
    public void setUp() {
View Full Code Here

            }
            line = line.substring(end + 1);
            lineCounter++;
        }
        Vector vector = new SequentialAccessSparseVector(cardinality);
        vector.assign(features);
        log.debug(String.format("Vector: label:%s Fields: %d", docLabel,
                vector.size()));

        return new NamedVector(vector, docLabel);
    }
View Full Code Here

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

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

  @Test
  public void testCanopyAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new Canopy(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("C-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  @Test
  public void testCanopyAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new Canopy(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("C-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
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.Cluster(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("CL-123{n=0 c=[0:1.100, 2:3.300] r=[]}", 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.