Example usage for org.apache.mahout.math.hadoop MatrixColumnMeansJob run

List of usage examples for org.apache.mahout.math.hadoop MatrixColumnMeansJob run

Introduction

In this page you can find the example usage for org.apache.mahout.math.hadoop MatrixColumnMeansJob run.

Prototype

public static Vector run(Configuration initialConf, Path inputPath, Path outputVectorTmpPath,
        String vectorClass) throws IOException 

Source Link

Document

Job for calculating column-wise mean of a DistributedRowMatrix

Usage

From source file:at.illecker.hadoop.rootbeer.examples.matrixmultiplication.DistributedRowMatrix.java

License:Apache License

/**
 * Returns the column-wise mean of a DistributedRowMatrix
 * // w  w w .j a v a 2s. c  o m
 * @param vectorClass desired class for the column-wise mean vector e.g.
 *          RandomAccessSparseVector, DenseVector
 * @return Vector containing the column-wise mean of this
 */
public Vector columnMeans(String vectorClass) throws IOException {
    Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime())));
    Configuration initialConf = getConf() == null ? new Configuration() : getConf();
    String vectorClassFull = "org.apache.mahout.math." + vectorClass;
    Vector mean = MatrixColumnMeansJob.run(initialConf, rowPath, outputVectorTmpPath, vectorClassFull);
    if (!keepTempFiles) {
        FileSystem fs = outputVectorTmpPath.getFileSystem(conf);
        fs.delete(outputVectorTmpPath, true);
    }
    return mean;
}