Package de.jungblut.clustering.model

Examples of de.jungblut.clustering.model.ClusterCenter


    Path centroids = new Path(conf.get("centroid.path"));
    FileSystem fs = FileSystem.get(conf);

    try (SequenceFile.Reader reader = new SequenceFile.Reader(fs, centroids,
        conf)) {
      ClusterCenter key = new ClusterCenter();
      IntWritable value = new IntWritable();
      int index = 0;
      while (reader.next(key, value)) {
        ClusterCenter clusterCenter = new ClusterCenter(key);
        clusterCenter.setClusterIndex(index++);
        centers.add(clusterCenter);
      }
    }
    distanceMeasurer = new ManhattanDistance();
  }
View Full Code Here


  @Override
  protected void map(ClusterCenter key, VectorWritable value, Context context)
      throws IOException, InterruptedException {

    ClusterCenter nearest = null;
    double nearestDistance = Double.MAX_VALUE;
    for (ClusterCenter c : centers) {
      double dist = distanceMeasurer.measureDistance(c.getCenterVector(),
          value.getVector());
      if (nearest == null) {
View Full Code Here

      else
        newCenter = newCenter.add(value.getVector());
    }

    newCenter = newCenter.divide(vectorList.size());
    ClusterCenter center = new ClusterCenter(newCenter);
    centers.add(center);
    for (VectorWritable vector : vectorList) {
      context.write(center, vector);
    }

    if (center.converged(key))
      context.getCounter(Counter.CONVERGED).increment(1);

  }
View Full Code Here

        Path path = status.getPath();
        if (!path.getName().equals("_SUCCESS")) {
          LOG.info("FOUND " + path.toString());
          try (SequenceFile.Reader reader = new SequenceFile.Reader(fs, path,
              conf)) {
            ClusterCenter key = new ClusterCenter();
            VectorWritable v = new VectorWritable();
            while (reader.next(key, v)) {
              LOG.info(key + " / " + v);
            }
          }
View Full Code Here

  public static void writeExampleVectors(Configuration conf, Path in,
      FileSystem fs) throws IOException {
    try (SequenceFile.Writer dataWriter = SequenceFile.createWriter(fs, conf,
        in, ClusterCenter.class, VectorWritable.class)) {
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(1, 2));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(16, 3));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(3, 3));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(2, 2));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(2, 3));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(25, 1));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(7, 6));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(6, 5));
      dataWriter.append(new ClusterCenter(new VectorWritable(0, 0)),
          new VectorWritable(-1, -23));
    }
  }
View Full Code Here

  public static void writeExampleCenters(Configuration conf, Path center,
      FileSystem fs) throws IOException {
    try (SequenceFile.Writer centerWriter = SequenceFile.createWriter(fs, conf,
        center, ClusterCenter.class, IntWritable.class)) {
      final IntWritable value = new IntWritable(0);
      centerWriter.append(new ClusterCenter(new VectorWritable(1, 1)), value);
      centerWriter.append(new ClusterCenter(new VectorWritable(5, 5)), value);
    }
  }
View Full Code Here

TOP

Related Classes of de.jungblut.clustering.model.ClusterCenter

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.