Package org.apache.mahout.clustering

Examples of org.apache.mahout.clustering.ClusterClassifier


    int id = 0;
    for (Vector point : points) {
      initialClusters.add(new org.apache.mahout.clustering.kmeans.Cluster(
          point, id++, measure));
    }
    ClusterClassifier prior = new ClusterClassifier(initialClusters);
    Path priorClassifier = new Path(output, "clusters-0");
    writeClassifier(prior, conf, priorClassifier);
   
    int maxIter = 10;
    ClusteringPolicy policy = new KMeansClusteringPolicy();
    new ClusterIterator(policy).iterateSeq(samples, priorClassifier, output, maxIter);
    for (int i = 1; i <= maxIter; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      CLUSTERS.add(posterior.getModels());
    }
  }
View Full Code Here


  protected static ClusterClassifier readClassifier(Configuration config, Path path) throws IOException {
    SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
    try {
      Writable key = new Text();
      ClusterClassifier classifierOut = new ClusterClassifier();
      reader.next(key, classifierOut);
      return classifierOut;
    } finally {
      Closeables.closeQuietly(reader);
    }
View Full Code Here

    List<Cluster> initialClusters = Lists.newArrayList();
    int id = 0;
    for (Vector point : points) {
      initialClusters.add(new SoftCluster(point, id++, measure));
    }
    ClusterClassifier prior = new ClusterClassifier(initialClusters);
    Path priorClassifier = new Path(output, "classifier-0");
    writeClassifier(prior, conf, priorClassifier);
   
    ClusteringPolicy policy = new FuzzyKMeansClusteringPolicy();
    new ClusterIterator(policy).iterateSeq(samples, priorClassifier, output, maxIterations);
    for (int i = 1; i <= maxIterations; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      CLUSTERS.add(posterior.getModels());
    }
  }
View Full Code Here

                                                       int numIterations) throws IOException {
    List<Cluster> models = Lists.newArrayList();
    for (Model<VectorWritable> cluster : modelDist.sampleFromPrior(numClusters)) {
      models.add((Cluster) cluster);
    }
    ClusterClassifier prior = new ClusterClassifier(models);
    Path samples = new Path("samples");
    Path output = new Path("output");
    Path priorClassifier = new Path(output, "clusters-0");
    Configuration conf = new Configuration();
    writeClassifier(prior, conf, priorClassifier);
   
    ClusteringPolicy policy = new DirichletClusteringPolicy(numClusters, numIterations);
    new ClusterIterator(policy).iterateSeq(samples, priorClassifier, output, numIterations);
    for (int i = 1; i <= numIterations; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      List<Cluster> clusters = Lists.newArrayList();
      for (Cluster cluster : posterior.getModels()) {
        if (isSignificant(cluster)) {
          clusters.add(cluster);
        }
      }
      CLUSTERS.add(clusters);
View Full Code Here

    List<Cluster> initialClusters = new ArrayList<Cluster>();
    int id = 0;
    for (Vector point : points) {
      initialClusters.add(new SoftCluster(point, id++, measure));
    }
    ClusterClassifier prior = new ClusterClassifier(initialClusters);
    Path priorClassifier = new Path(output, "classifier-0");
    writeClassifier(prior, conf, priorClassifier);
   
    ClusteringPolicy policy = new FuzzyKMeansClusteringPolicy();
    new ClusterIterator(policy).iterate(samples, priorClassifier, output, maxIterations);
    for (int i = 1; i <= maxIterations; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      CLUSTERS.add(posterior.getModels());
    }
  }
View Full Code Here

                                                       int numIterations) throws IOException {
    List<Cluster> models = new ArrayList<Cluster>();
    for (Model<VectorWritable> cluster : modelDist.sampleFromPrior(numClusters)) {
      models.add((Cluster) cluster);
    }
    ClusterClassifier prior = new ClusterClassifier(models);
    Path samples = new Path("samples");
    Path output = new Path("output");
    Path priorClassifier = new Path(output, "clusters-0");
    Configuration conf = new Configuration();
    writeClassifier(prior, conf, priorClassifier);
   
    ClusteringPolicy policy = new DirichletClusteringPolicy(numClusters, numIterations);
    new ClusterIterator(policy).iterate(samples, priorClassifier, output, numIterations);
    for (int i = 1; i <= numIterations; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      List<Cluster> clusters = new ArrayList<Cluster>();   
      for (Cluster cluster : posterior.getModels()) {
        if (isSignificant(cluster)) {
          clusters.add(cluster);
        }
      }
      CLUSTERS.add(clusters);
View Full Code Here

    int id = 0;
    for (Vector point : points) {
      initialClusters.add(new org.apache.mahout.clustering.kmeans.Cluster(
          point, id++, measure));
    }
    ClusterClassifier prior = new ClusterClassifier(initialClusters);
    Path priorClassifier = new Path(output, "clusters-0");
    writeClassifier(prior, conf, priorClassifier);
   
    int maxIter = 10;
    ClusteringPolicy policy = new KMeansClusteringPolicy();
    new ClusterIterator(policy).iterate(samples, priorClassifier, output, maxIter);
    for (int i = 1; i <= maxIter; i++) {
      ClusterClassifier posterior = readClassifier(conf, new Path(output, "classifier-" + i));
      CLUSTERS.add(posterior.getModels());
    }
  }
View Full Code Here

  }

  protected static ClusterClassifier readClassifier(Configuration config, Path path) throws IOException {
    SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
    Writable key = new Text();
    ClusterClassifier classifierOut = new ClusterClassifier();
    reader.next(key, classifierOut);
    reader.close();
    return classifierOut;
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.ClusterClassifier

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.