Mahout版本:0.7,hadoop版本:1.0.4,jdk:1.7.0_25 64bit。
1. Job 篇
接上篇,分析到EigenVerificationJob的run方法:
public int run(Path corpusInput, Path eigenInput, Path output, Path tempOut, double maxError, double minEigenValue, boolean inMemory, Configuration conf) throws IOException { this.outPath = output; this.tmpOut = tempOut; this.maxError = maxError; this.minEigenValue = minEigenValue; if (eigenInput != null && eigensToVerify == null) { prepareEigens(conf, eigenInput, inMemory); } DistributedRowMatrix c = new DistributedRowMatrix(corpusInput, tempOut, 1, 1); c.setConf(conf); corpus = c; // set up eigenverifier and orthoverifier TODO: allow multithreaded execution eigenVerifier = new SimpleEigenVerifier(); // we don't currently verify orthonormality here. // VectorIterable pairwiseInnerProducts = computePairwiseInnerProducts(); Map<MatrixSlice, EigenStatus> eigenMetaData = verifyEigens(); List<Map.Entry<MatrixSlice, EigenStatus>> prunedEigenMeta = pruneEigens(eigenMetaData); saveCleanEigens(new Configuration(), prunedEigenMeta); return 0; }
这里先明确几个输入参数,inputPath、outputPath、tempPath就不用多说了,eigenPath就是上篇最后生成的rawEigenvectors文件;inMemory是false、maxError是0.05,minEigenValue是0.0;顺便说一下,如果直接运行这个类是不行的,比如像下面这样调用:
package mahout.fansy.svd; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.mahout.math.hadoop.decomposer.EigenVerificationJob; public class RunEigenVerificationJob { /** * 调用EigenVerificationJob */ private static Path prefix=new Path("hdfs://ubuntu:9000"); public static void main(String[] args) throws IOException { Path inputPath=new Path(prefix,"/svd/input/wine"); Path rawEigenVectorPath=new Path(prefix,"/svd/output1/rawEigenvectors"); Path outputPath=new Path(prefix,"/svd/output1/cleanEigenvectors"); Path outputTmpPath=new Path(prefix,"/svd/temp"); double maxError=0.5; double minEigenvalue=0.0; boolean inMemory=false; Configuration conf=new Configuration(); conf.set("mapred.job.tracker", "ubuntu:9001"); int result=new EigenVerificationJob().run(inputPath, rawEigenVectorPath, outputPath, outputTmpPath, maxError, minEigenvalue, inMemory, conf); System.out.println("result success?"+(result==0?true:false)); } }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索mahout
, path
, conf
, new
, configuration
, inmemory
, SVD
ioException
mahout源码分析、mahout源码、mahout源码下载、mahout kmeans源码、mahout实践指南 源码,以便于您获取更多的相关知识。
时间: 2023-09-19