Examples of VectorWritable


Examples of org.apache.mahout.math.VectorWritable

      VectorModelDistribution.class);
    VectorModelDistribution factory = cl.newInstance();
   
    Class<? extends Vector> vcl = ccl.loadClass(modelPrototype).asSubclass(Vector.class);
    Constructor<? extends Vector> v = vcl.getConstructor(int.class);
    factory.setModelPrototype(new VectorWritable(v.newInstance(prototypeSize)));
    return new DirichletState<VectorWritable>(factory, numModels, alpha_0);
  }
View Full Code Here

Examples of org.apache.mahout.math.VectorWritable

                     OutputCollector<Text,DirichletCluster<VectorWritable>> output,
                     Reporter reporter) throws IOException {
    int k = Integer.parseInt(key.toString());
    Model<VectorWritable> model = newModels[k];
    while (values.hasNext()) {
      VectorWritable v = values.next();
      model.observe(v);
    }
    model.computeParameters();
    DirichletCluster<VectorWritable> cluster = state.getClusters().get(k);
    cluster.setModel(model);
View Full Code Here

Examples of org.apache.mahout.math.VectorWritable

 
  @Override
  public void close() throws IOException {
    for (Canopy canopy : canopies) {
      Vector centroid = canopy.computeCentroid();
      VectorWritable vw = new VectorWritable();
      vw.set(centroid);
      outputCollector.collect(new Text("centroid"), vw);
    }
    super.close();
  }
View Full Code Here

Examples of org.apache.mahout.math.VectorWritable

                     OutputCollector<WritableComparable<?>,VectorWritable> output,
                     Reporter reporter) throws IOException {
   
    Vector vector = new RandomAccessSparseVector(key.toString(), dimension, 10);
    while (values.hasNext()) {
      VectorWritable value = values.next();
      value.get().addTo(vector);
    }
    if (normPower != PartialVectorMerger.NO_NORMALIZING) {
      vector = vector.normalize(normPower);
    }
    if (sequentialAccess) {
View Full Code Here

Examples of org.apache.mahout.math.VectorWritable

                                          OutputCollector<Text,VectorWritable> collector,
                                          Reporter reporter) throws IOException {
    double minDist = Double.MAX_VALUE;
    Canopy closest = null;
    boolean isCovered = false;
    VectorWritable vw = new VectorWritable();
    for (Canopy canopy : canopies) {
      double dist = measure.distance(canopy.getCenter().getLengthSquared(), canopy.getCenter(), point);
      if (dist < t1) {
        isCovered = true;
        vw.set(point);
        collector.collect(new Text(canopy.getIdentifier()), vw);
        reporter.setStatus("Emit Canopy ID:" + canopy.getIdentifier());
      } else if (dist < minDist) {
        minDist = dist;
        closest = canopy;
      }
    }
    // if the point is not contained in any canopies (due to canopy centroid
    // clustering), emit the point to the closest covering canopy.
    vw.set(point);
    if (!isCovered) {
      collector.collect(new Text(closest.getIdentifier()), vw);
      reporter.setStatus("Emit Closest Canopy ID:" + closest.getIdentifier());
    }
  }
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.