Examples of WeightedVectorWritable


Examples of org.apache.mahout.clustering.WeightedVectorWritable

   
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(
      clusterOutput + Cluster.CLUSTERED_POINTS_DIR +"/part-m-00000"), conf);
   
    IntWritable key = new IntWritable();
    WeightedVectorWritable value = new WeightedVectorWritable();
    while (reader.next(key, value)) {
      System.out.println("Cluster: " + key.toString() + " "
                         + value.getVector().asFormatString());
    }
    reader.close();
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

   
    SequenceFile.Reader reader = new SequenceFile.Reader(fs,
        new Path(clusterOutput + Cluster.CLUSTERED_POINTS_DIR + "/part-00000"), conf);
   
    IntWritable key = new IntWritable();
    WeightedVectorWritable value = new WeightedVectorWritable();
    while (reader.next(key, value)) {
       System.out.println(key.toString() + " belongs to cluster "
       + value.toString());
    }
    reader.close();
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

    SequenceFile.Reader reader = new SequenceFile.Reader(fs,
        new Path("output/" + Cluster.CLUSTERED_POINTS_DIR
                 + "/part-m-00000"), conf);
   
    IntWritable key = new IntWritable();
    WeightedVectorWritable value = new WeightedVectorWritable();
    while (reader.next(key, value)) {
      System.out.println(value.toString() + " belongs to cluster "
                         + key.toString());
    }
    reader.close();
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      List<WeightedVectorWritable> list = pointClusterInfo.get(clusterId);
      if (list == null) {
        list = new ArrayList<WeightedVectorWritable>();
        pointClusterInfo.put(clusterId, list);
      }
      list.add(new WeightedVectorWritable(clusterPdf, point));
      double totalProb = 0;
      for (int i = 0; i < clusterList.size(); i++) {
        //SoftCluster cluster = clusterList.get(i);
        double probWeight = clusterer.computeProbWeight(clusterDistanceList.get(i), clusterDistanceList);
        totalProb += probWeight;
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

          DefaultOptionCreator.SEQUENTIAL_METHOD
      };
      new FuzzyKMeansDriver().run(args);
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(output, "clusteredPoints/part-m-0"), conf);
      Writable key = new IntWritable();
      Writable out = new WeightedVectorWritable();
      while (reader.next(key, out)) {
        // make sure we can read all the clusters
      }
      reader.close();
    }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

          optKey(DefaultOptionCreator.OVERWRITE_OPTION)
      };
      ToolRunner.run(new Configuration(), new FuzzyKMeansDriver(), args);
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(output, "clusteredPoints/part-m-00000"), conf);
      Writable key = new IntWritable();
      Writable out = new WeightedVectorWritable();
      while (reader.next(key, out)) {
        // make sure we can read all the clusters
      }
      reader.close();
    }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

    FileSystem fs = FileSystem.get(conf);
    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 weighted vector
    WeightedVectorWritable value = new WeightedVectorWritable();

    int id = 0;
    while (reader.next(clusterId, value)) {
      log.info("{}: {}", id++, clusterId.get());
      clusterId = new IntWritable(0);
      value = new WeightedVectorWritable();
    }
    reader.close();

    // TODO: output format???
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      try {
        Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
        MeanShiftCanopy canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
        while (reader.next(key, canopy)) {
          MeanShiftCanopy closest = MeanShiftCanopyClusterer.findCoveringCanopy(canopy, clusters);
          writer.append(new IntWritable(closest.getId()), new WeightedVectorWritable(1, canopy.getCenter()));
          canopy = reader.getValueClass().asSubclass(MeanShiftCanopy.class).newInstance();
        }
      } finally {
        reader.close();
        writer.close();
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

    int vectorId = canopy.getId();
    for (MeanShiftCanopy msc : canopies) {
      for (int containedId : msc.getBoundPoints().toList()) {
        if (vectorId == containedId) {
          context.write(new IntWritable(msc.getId()),
                         new WeightedVectorWritable(1, canopy.getCenter()));
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.mahout.clustering.WeightedVectorWritable

      if ((distance < nearestDistance) || (nearestCluster == null)) {
        nearestCluster = cluster;
        nearestDistance = distance;
      }
    }
    context.write(new IntWritable(nearestCluster.getId()), new WeightedVectorWritable(1, vector));
  }
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.