2

这类似于这个问题:Weka Predictions to CSV,但来自命令行。

我有以下 Weka 命令:

java -Xmx10G weka.classifiers.meta.FilteredClassifier \
-t test_data.arff -d  prediction.model -p first -no-cv \
-F "weka.filters.unsupervised.attribute.Remove -R 1" \
-W hr.irb.fastRandomForest.FastRandomForest \
-- -I 512 -K 0 -S 512

这给了我以下数据:

=== Predictions on training data ===

inst#     actual  predicted error prediction (primary_key)
 1        1:0        1:0       0.996 (r153)
 2        1:0        1:0       0.994 (r756)
 3        1:0        1:0       0.97  (r23)
 4        1:0        1:0       0.995 (r18153)
 5        1:0        1:0       0.947 (r2691)

这很好,但我想将此数据输出到 CSV 文件,以便轻松加载到数据库中。我如何告诉 Weka 我想要将我的预测以 CSV 格式导出?

注意:使用 Weka 版本 3.6.6

4

1 回答 1

1

这对我有用:

java -Xmx28G weka.Run -no-scan weka.classifiers.meta.FilteredClassifier \
-classifications "weka.classifiers.evaluation.output.prediction.CSV -p first" \
-l $model \
-T $dataset \
|tail -n+6 |head -n -1
#note: |tail -n+6  <-- removes the header of file
#      |head -n -1 <-- removes the footer of file

我必须升级到 Weka 3.7.9 才能让它工作。

于 2013-12-16T18:04:17.500 回答