Examples of WeightedVectorWritable


Examples of org.apache.mahout.clustering.WeightedVectorWritable

        maxPdf = pdf;
        clusterId = i;
      }
    }
    //System.out.println(i + ": " + ClusterBase.formatVector(vector.get(), null));
    writer.append(new IntWritable(clusterId), new WeightedVectorWritable(maxPdf, vector.get()));
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

        clusterId = clusters.get(i).getId();
        clusterPdf = pdf;
      }
    }
    // System.out.println("cluster-" + clusterId + ": " + ClusterBase.formatVector(point, null));
    context.write(new IntWritable(clusterId), new WeightedVectorWritable(clusterPdf, point));
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      throws IOException, InterruptedException {
    for (int i = 0; i < clusters.size(); i++) {
      double pdf = pi.get(i);
      if (pdf > threshold) {
        // System.out.println("cluster-" + clusterId + ": " + ClusterBase.formatVector(point, null));
        context.write(new IntWritable(i), new WeightedVectorWritable(pdf, point));
      }
    }
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      throws IOException {
    for (int i = 0; i < clusters.size(); i++) {
      double pdf = pi.get(i);
      if (pdf > threshold) {
        // System.out.println("cluster-" + clusterId + ": " + ClusterBase.formatVector(point, null));
        writer.append(new IntWritable(i), new WeightedVectorWritable(pdf, point));
      }
    }
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

        clusterId = clusters.get(i).getId();
        clusterPdf = pdf;
      }
    }
    // System.out.println("cluster-" + clusterId + ": " + ClusterBase.formatVector(point, null));
    writer.append(new IntWritable(clusterId), new WeightedVectorWritable(clusterPdf, point));
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      try {
        Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
        VectorWritable vw = reader.getValueClass().asSubclass(VectorWritable.class).newInstance();
        while (reader.next(key, vw)) {
          Canopy closest = clusterer.findClosestCanopy(vw.get(), clusters);
          writer.append(new IntWritable(closest.getId()), new WeightedVectorWritable(1, vw.get()));
          vw = reader.getValueClass().asSubclass(VectorWritable.class).newInstance();
        }
      } finally {
        reader.close();
        writer.close();
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      int[] expect = EXPECTED_NUM_POINTS[k];
      DummyOutputCollector<IntWritable, WeightedVectorWritable> collector = new DummyOutputCollector<IntWritable, WeightedVectorWritable>();
      // The key is the clusterId
      IntWritable clusterId = new IntWritable(0);
      // The value is the weighted vector
      WeightedVectorWritable value = new WeightedVectorWritable();
      while (reader.next(clusterId, value)) {
        collector.collect(clusterId, value);
        clusterId = new IntWritable(0);
        value = new WeightedVectorWritable();
      }
      reader.close();
      assertEquals("clusters[" + k + ']', expect.length, collector.getKeys().size());
    }
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      int[] expect = EXPECTED_NUM_POINTS[k];
      DummyOutputCollector<IntWritable, WeightedVectorWritable> collector = new DummyOutputCollector<IntWritable, WeightedVectorWritable>();
      // The key is the clusterId
      IntWritable clusterId = new IntWritable(0);
      // The value is the weighted vector
      WeightedVectorWritable value = new WeightedVectorWritable();
      while (reader.next(clusterId, value)) {
        collector.collect(clusterId, value);
        clusterId = new IntWritable(0);
        value = new WeightedVectorWritable();
      }
      reader.close();
      if (k == 2) {
        // cluster 3 is empty so won't appear in output
        assertEquals("clusters[" + k + ']', expect.length - 1, collector.getKeys().size());
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

    SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(clusteredPointsPath, "part-m-00000"), conf);

    // The key is the clusterId
    IntWritable clusterId = new IntWritable(0);
    // The value is the vector
    WeightedVectorWritable value = new WeightedVectorWritable();
    while (reader.next(clusterId, value)) {
      collector.collect(clusterId, value);
      clusterId = new IntWritable(0);
      value = new WeightedVectorWritable();

    }
    reader.close();

    assertEquals("num points[0]", 4, collector.getValue(new IntWritable(0)).size());
View Full Code Here

Examples of org.apache.mahout.clustering.classify.WeightedVectorWritable

        for (Pair<Writable, ClusterWritable> record
            : new SequenceFileIterable<Writable, ClusterWritable>(s.getPath(), conf)) {
          ClusterWritable clusterWritable = record.getSecond();
          MeanShiftCanopy canopy = (MeanShiftCanopy) clusterWritable.getValue();
          MeanShiftCanopy closest = MeanShiftCanopyClusterer.findCoveringCanopy(canopy, clusters);
          writer.append(new IntWritable(closest.getId()), new WeightedVectorWritable(1, canopy.getCenter()));
        }
      } finally {
        Closeables.close(writer, false);
      }
    }
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.