2

我正在尝试使用 Mahout 中的朴素贝叶斯分类器对一些产品数据进行分类。

我曾经solr将两个数据集都转换为 lucene 索引,然后使用 Mahout split 命令创建训练集和保持集。这似乎工作正常。

现在我已经到了用 trainnb 训练朴素贝叶斯模型的阶段,但我收到以下错误:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
        at org.apache.mahout.classifier.naivebayes.BayesUtils.writeLabelIndex(BayesUtils.java:119)
        at org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob.createLabelIndex(TrainNaiveBayesJob.java:152)
        at org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob.run(TrainNaiveBayesJob.java:92)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
        at org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob.main(TrainNaiveBayesJob.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
        at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
        at org.apache.mahout.driver.MahoutDriver.main(MahoutDriver.java:195)

这是我的命令输入:

$MAHOUT_HOME/bin/./mahout trainnb -i ~/training_output/Amazon_training_output/ -el -o ~/model/Amazon -li ~/labelindex/Amazon -ow -c

在这种情况下,错误是什么意思,我该如何解决?

有没有可能是我原来的索引是罪魁祸首?

4

1 回答 1

0

也许您的密钥格式不正确?根据代码,我看到关键是期待 /string/int

第 119、131 行 http://grepcode.com/file/repository.cloudera.com/content/repositories/releases/org.apache.mahout/mahout-core/0.7-cdh4.1.3/org/apache/mahout/classifier/ naivebayes/BayesUtils.java?av=f

于 2014-02-21T19:01:53.413 回答