从命令行使用 InputMappedClassifier
Using InputMappedClassifier From Command Line
我正在尝试 运行 使用 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
我正在尝试 运行 使用 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