mahout toString空重

时间:2014-12-18 07:32:59

标签: hadoop mahout training-data

我在Mahout中使用Naive Bayes进行分类。 在我训练模型后,我使用一个文档来测试模型。

我将数据传输到矢量

./bin/mahout seqdirectory -i /home/d/mahoutTest/ -o /home/d/seqMahout1
./bin/mahout seq2sparse -i /home/d/seqMahout1/ -o /home/d/vecMahout1 -lnorm -nv -ow -wt tfidf

但是当我尝试测试数据时,出现错误

./bin/mahout testnb -i /home/d/vecMahout1/tfidf-vectors/ -m /tmp/mahout-work-d/model/ -l /tmp/mahout-work-d/labelindex -o /home/d/out10/

SLF4J: Failed toString() invocation on an object of type [org.apache.mahout.classifier.ResultAnalyzer]
org.apache.commons.math3.exception.MathIllegalArgumentException: weigth array must contain at least one non-zero value
    at org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic.test(AbstractUnivariateStatistic.java:309)
    at org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic.test(AbstractUnivariateStatistic.java:245)
    at org.apache.commons.math3.stat.descriptive.moment.Mean.evaluate(Mean.java:211)
    at org.apache.commons.math3.stat.descriptive.moment.Mean.evaluate(Mean.java:254)
    at org.apache.mahout.classifier.ConfusionMatrix.getWeightedPrecision(ConfusionMatrix.java:143)
    at org.apache.mahout.classifier.ResultAnalyzer.toString(ResultAnalyzer.java:114)
    at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:304)
    at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:276)
    at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:230)
    at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:152)
    at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:345)
    at org.apache.mahout.classifier.naivebayes.test.TestNaiveBayesDriver.run(TestNaiveBayesDriver.java:107)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.mahout.classifier.naivebayes.test.TestNaiveBayesDriver.main(TestNaiveBayesDriver.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:72)
    at org.apache.hadoop.util.ProgramDriver.run(ProgramDriver.java:144)
    at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:152)
    at org.apache.mahout.driver.MahoutDriver.main(MahoutDriver.java:195)

1 个答案:

答案 0 :(得分:0)

如果" true"测试项目的标签不在训练集中。你看到像这样的警告:

15/07/07 15:20:12 WARN ConfusionMatrix: Label YOUR TEST LABEL HERE did not appear in the training examples