Package org.apache.mahout.math

Examples of org.apache.mahout.math.VectorWritable


      csv.printf("%s,%s", f.getParentFile().getName(), f.getName());
      for (int i = 0; i < v.size(); i++) {
        csv.printf(",%.5f", v.get(i));
      }
      csv.printf("\n");
      sf.append(new Text(f.getParentFile().getName()), new VectorWritable(v));
    }
  }
View Full Code Here


    FileSystem fs = FileSystem.get(conf);
   
    Path path = new Path("appledata/apples");
    SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf,
        path, Text.class, VectorWritable.class);
    VectorWritable vec = new VectorWritable();
    for (NamedVector vector : apples) {
      vec.set(vector);
      writer.append(new Text(vector.getName()), vec);
    }
    writer.close();
   
    SequenceFile.Reader reader = new SequenceFile.Reader(fs,
        new Path("appledata/apples"), conf);
   
    Text key = new Text();
    VectorWritable value = new VectorWritable();
    while (reader.next(key, value)) {
      System.out.println(key.toString() + " " + value.get().asFormatString());
    }
    reader.close();
  }
View Full Code Here

    for (IntWritable intWritable : itemIndex2s) {
      int itemIndex2 = intWritable.get();
      cooccurrenceRow.set(itemIndex2,
          cooccurrenceRow.get(itemIndex2) + 1.0);
    }
    context.write(itemIndex1, new VectorWritable(cooccurrenceRow));
  }
View Full Code Here

        = new DefaultStringifier<Map<String,Integer>>(
              conf, GenericsUtil.getClass(dictionary));
    dictionary = mapStringifier.fromString(conf.get("dictionary"));
   
    splitter = Pattern.compile("<sep>");
    writer = new VectorWritable();
  }
View Full Code Here

    Vector partial = null;
    for (VectorWritable vectorWritable : values) {
      partial = partial == null ? vectorWritable.get() : partial
          .plus(vectorWritable.get());
    }
    context.write(key, new VectorWritable(partial));
  }
View Full Code Here

      throws IOException, InterruptedException {
    Vector userVector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    for (VarLongWritable itemPref : itemPrefs) {
      userVector.set((int) itemPref.get(), 1.0f);
    }
    context.write(userID, new VectorWritable(userVector));
  }
View Full Code Here

    for (int i = 0; i < userIDs.size(); i++) {
      long userID = userIDs.get(i);
      float prefValue = prefValues.get(i);
      Vector partialProduct = cooccurrenceColumn.times(prefValue);
      context.write(new VarLongWritable(userID),
          new VectorWritable(partialProduct));
    }
  }
View Full Code Here

   
    SequenceFile.Reader reader = new SequenceFile.Reader(fs,
        new Path(vectorsFolder, "part-r-00000"), conf);
    Text key = new Text();
    VectorWritable value = new VectorWritable();
    while (reader.next(key, value)) {
      System.out.println(key.toString() + " = > "
                         + value.get().asFormatString());
    }
    reader.close();
  }
View Full Code Here

                                       Configuration conf) throws IOException {
    Path path = new Path(fileName);
    SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf,
        path, LongWritable.class, VectorWritable.class);
    long recNum = 0;
    VectorWritable vec = new VectorWritable();
    for (Vector point : points) {
      vec.set(point);
      writer.append(new LongWritable(recNum++), vec);
    }
    writer.close();
  }
View Full Code Here

    FileSystem fs = FileSystem.get(conf);
    String vectorsFolder = inputDir + "/tfidf-vectors";
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(vectorsFolder + "/part-r-00000"), conf);
    List<Vector> points = new ArrayList<Vector>();
    Text key = new Text();
    VectorWritable value = new VectorWritable();
   
    while (reader.next(key, value)) {
      points.add(value.get());
    }
    System.out.println(points.size());
    reader.close();
    List<Canopy> canopies = CanopyClusterer.createCanopies(points, new CosineDistanceMeasure(), 0.8, 0.7);
    List<Cluster> clusters = new ArrayList<Cluster>();
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.VectorWritable

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.