以 CSV(或文本)格式导出 Weka 命令行预测,仅预测值和原始值

Exporting Weka command Line prediction in CSV (or text), only predicted and original values

我从命令行使用 Weka,因为我有一个批处理文件 运行 多个分类器 10 倍。所以我 运行 实验了 10 次,然后对它们的指标(准确性等)取平均值。现在我有很多输出文件,因此手动评估它们非常耗时。我的问题是我们可以将 weka 命令行的输出预测值导出到不同列中的 CSV 文件吗? 例如:java -cp weka.jar weka.classifiers.trees.J48 -t data/iris.arff -T data/iris.arff -p 0 > iris.txt 为您提供文本甚至 .CSV 文件,但它们位于一列中。所以我们无法找到准确性、精确度等。如果我们可以在一列中有预测,而在另一列中有原始数据,那么我们就可以轻松找到其他指标。 This is the most relevant but this has the same issue.。 使用此代码 java -cp weka.jar weka.classifiers.trees.J48 -t data/iris.arff -T data/iris.arff > iris.csv 我可以获得详细文件,但它们位于一栏中,如下所示: all metrics but in one column so taking average of them is not easy.

-p 选项早已被弃用。相反,使用 -classifications class+options 选项(参见 javadoc of Evaluation class). If you want CSV output, you can the following class: weka.classifiers.evaluation.output.CSV.

顺便说一句,如果您正在考虑比较分类器,您应该使用 Weka Experimenter。默认情况下,它会执行 10 次 10 折交叉验证,并为您提供所选统计数据的均值、标准差和显着性 losses/wins。