gpt4 book ai didi

java - 从命令行使用 InputMappedClassifier

转载 作者:行者123 更新时间:2023-11-30 09:37:56 26 4
gpt4 key购买 nike

我正在尝试使用 InputMappedClassifier 运行分类器,因为我知道测试 arff 缺少训练 arff 中的一些属性。但是,当我运行时:

java -cp ./weka.jar weka.classifiers.misc.InputMappedClassifier -t aa/lang-train.arff \
-T aa/lang-test.arff -W weka.classifiers.trees.J48 -classifications \
weka.classifiers.evaluation.output.prediction.PlainText

它生成异常:

java.lang.IllegalArgumentException: Invalid class index: 2466
at weka.core.Instances.setClassIndex(Instances.java:1293)
at weka.core.converters.ConverterUtils$DataSource.getStructure(ConverterUtils.java:346)
at weka.classifiers.evaluation.output.prediction.AbstractOutput.printClassifications(AbstractOutput.java:625)
at weka.classifiers.evaluation.output.prediction.AbstractOutput.print(AbstractOutput.java:702)
at weka.classifiers.evaluation.Evaluation.evaluateModel(Evaluation.java:1572)
at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:649)
at weka.classifiers.AbstractClassifier.runClassifier(AbstractClassifier.java:297)
at weka.classifiers.misc.InputMappedClassifier.main(InputMappedClassifier.java:943)

如果我在没有-classifications的情况下运行它,它就可以工作。如何获得分类?

最佳答案

您为 InputMappedClassifier 提供了错误的选项。它提示你给它训练(-t)和测试(-T)数据。它支持以下内容:

Options specific to weka.classifiers.misc.InputMappedClassifier:

-I
Ignore case when matching attribute names and nominal values.
-M
Suppress the output of the mapping report.
-trim
Trim white space from either end of names before matching.
-L <path to model to load>
Path to a model to load. If set, this model
will be used for prediction and any base classifier
specification will be ignored. Environment variables
may be used in the path (e.g. ${HOME}/myModel.model)
-W
Full name of base classifier.
(default: weka.classifiers.rules.ZeroR)
-output-debug-info
If set, classifier is run in debug mode and
may output additional info to the console
-do-not-check-capabilities
If set, classifier capabilities are not checked before classifier is built
(use with caution).

所以你的命令应该是这样的:

java -cp ./weka.jar weka.classifiers.misc.InputMappedClassifier -W weka.classifiers.trees.J48 \
-t aa/lang-train.arff \
-T aa/lang-test.arff \
-classifications weka.classifiers.evaluation.output.prediction.PlainText

关于java - 从命令行使用 InputMappedClassifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28247240/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com