Example usage for org.apache.mahout.clustering.kmeans KMeansDriver KMeansDriver

List of usage examples for org.apache.mahout.clustering.kmeans KMeansDriver KMeansDriver

Introduction

In this page you can find the example usage for org.apache.mahout.clustering.kmeans KMeansDriver KMeansDriver.

Prototype

KMeansDriver

Source Link

Usage

From source file:com.modofo.molo.cluster.Clusterer.java

License:Apache License

public void cluster(String topicId) {
    String pointsPath = sampleDir + "/" + topicId + "/points.txt";
    String clustersPath = sampleDir + "/" + topicId + "/clusters.txt";
    String outputDir = tempDir + "/" + topicId;
    KMeansDriver kd = new KMeansDriver();
    String[] args = { "-i", pointsPath, "--clusters", clustersPath, "-o", outputDir, "--distanceMeasure",
            EuclideanDistanceMeasure.class.getName(), "--convergenceDelta", "0.001", "--maxIter", "2",
            "--clustering", "--overwrite", "--method", "sequential" // mapreduce
    };//from ww w.j  av  a 2  s  .  c  o  m

    try {
        kd.run(args);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.modofo.molo.cluster.Clusterer.java

License:Apache License

public void run(String topicId) {
    String inputDir = this.tempDir + "/" + topicId + "/" + topicId + "-vectors/tfidf-vectors";
    String clusterDir = this.tempDir + "/" + topicId + "-clusters";
    String outputDir = this.tempDir + "/" + topicId + "/cluster";
    String[] args = { "-i", inputDir, "-c", clusterDir, "-o", outputDir, "-dm",
            org.apache.mahout.common.distance.CosineDistanceMeasure.class.getName(), "-cd", "0.1", "-x", "10",
            "-k", "20", "-ow" };
    try {// w  w  w .ja v a 2 s  .c om
        KMeansDriver kd = new KMeansDriver();
        kd.setConf(new Configuration());
        kd.run(args);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:root.benchmark.kmeans.KMeansJob.java

License:Apache License

/**
 * {@inheritDoc}//ww  w.  j  a va 2s. c om
 */
@Override
public int run(String[] args) throws Exception {

    constructParameterList();
    for (String str : args) {
        System.out.println(str);
    }

    if (parseArguments(args) == null) {
        return -1;
    }

    initializeConfigurationParameters();

    printJobHeader();

    Configuration conf = getConf();

    URI inputURI = new URI(inputDirectory);

    FileSystem fs = FileSystem.get(inputURI, conf);

    Path input = new Path(inputDirectory);
    if (!fs.exists(input)) {
        System.err.println("Input Directory does not exist.");
        System.exit(2);
    }

    ToolRunner.run(conf, new KMeansDriver(), kmeansArgs);

    return 0;
}