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

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

Introduction

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

Prototype

@Override
    public int run(String[] args) throws Exception 

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  w  ww.ja  va  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 {/*  ww w  . java  2 s.c o  m*/
        KMeansDriver kd = new KMeansDriver();
        kd.setConf(new Configuration());
        kd.run(args);
    } catch (Exception e) {
        e.printStackTrace();
    }

}