Package org.apache.mahout.clustering.iterator

Examples of org.apache.mahout.clustering.iterator.DistanceMeasureCluster


    Vector prototype = getModelPrototype().get().like();
    for (int i = 0; i < prototype.size(); i++) {
      prototype.setQuick(i, UncommonDistributions.rNorm(0, 1));
    }
    for (int i = 0; i < howMany; i++) {
      result[i] = new DistanceMeasureCluster(prototype, i, measure);
    }
    return result;
  }
View Full Code Here


  private static void write(List<Cluster> clusterModels, SequenceFile.Writer writer,
      WeightedPropertyVectorWritable weightedPropertyVectorWritable,
      int maxValueIndex) throws IOException {
    Cluster cluster = clusterModels.get(maxValueIndex);

    DistanceMeasureCluster distanceMeasureCluster = (DistanceMeasureCluster) cluster;
    DistanceMeasure distanceMeasure = distanceMeasureCluster.getMeasure();
    double distance = distanceMeasure.distance(cluster.getCenter(), weightedPropertyVectorWritable.getVector());

    weightedPropertyVectorWritable.getProperties().put(new Text("distance"), new Text(Double.toString(distance)));
    writer.append(new IntWritable(cluster.getId()), weightedPropertyVectorWritable);
  }
View Full Code Here

  private void write(VectorWritable vw, Context context, int clusterIndex, double weight)
    throws IOException, InterruptedException {
    Cluster cluster = clusterModels.get(clusterIndex);
    clusterId.set(cluster.getId());

    DistanceMeasureCluster distanceMeasureCluster = (DistanceMeasureCluster) cluster;
    DistanceMeasure distanceMeasure = distanceMeasureCluster.getMeasure();
    double distance = distanceMeasure.distance(cluster.getCenter(), vw.get());

    Map<Text, Text> props = Maps.newHashMap();
    props.put(new Text("distance"), new Text(Double.toString(distance)));
    context.write(clusterId, new WeightedPropertyVectorWritable(weight, vw.get(), props));
View Full Code Here

    Vector prototype = getModelPrototype().get().like();
    for (int i = 0; i < prototype.size(); i++) {
      prototype.setQuick(i, UncommonDistributions.rNorm(0, 1));
    }
    for (int i = 0; i < howMany; i++) {
      result[i] = new DistanceMeasureCluster(prototype, i, measure);
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.iterator.DistanceMeasureCluster

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.