我已导入:
import org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob;
来自Mahout-Core-0.9-job 的
但是,当我尝试调用以下方法时:
String[] trainerArgs = {"-i", vectorsDirectory + "tfidf-vectors/",
"-o", modelDirectory,
"-l", labelIndex,
"-el", "-ow"};
TrainNaiveBayesJob thisTrainer = new TrainNaiveBayesJob();
thisTrainer.run(trainerArgs);
我收到以下错误:
java.lang.Exception: java.lang.IllegalStateException: Unable to find cached files!
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354)
Caused by: java.lang.IllegalStateException: Unable to find cached files!
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at org.apache.mahout.common.HadoopUtil.getCachedFiles(HadoopUtil.java:300)
at org.apache.mahout.common.HadoopUtil.getSingleCachedFile(HadoopUtil.java:281)
at org.apache.mahout.classifier.naivebayes.BayesUtils.readIndexFromCache(BayesUtils.java:146)
at org.apache.mahout.classifier.naivebayes.training.IndexInstancesMapper.setup(IndexInstancesMapper.java:41)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:223)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
我到底在哪里错过了这一点?有人可以指导我吗?
答案 0 :(得分:1)
只需将对NaiveBayes的呼叫更改为:
ToolRunner.run(new Configuration(), new TrainNaiveBayesJob(), trainerArgs);
解决了这个问题。