2

This is similar to this question: Weka Predictions to CSV, but from the command line.

I have the following Weka command:

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

Which gives me the following data:

=== 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)

This is great, but I would like to output this data to a CSV file for easy loading into a database. How do I tell Weka that I would like a CSV export of my predictions?

Note: using Weka version 3.6.6

Community
  • 1
  • 1
metrix
  • 1,486
  • 2
  • 11
  • 19

1 Answers1

1

This is what worked for me:

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

I had to upgrade to Weka 3.7.9 to get this to work.

metrix
  • 1,486
  • 2
  • 11
  • 19
  • This link: http://weka.wikispaces.com/Use+WEKA+in+your+Java+code looks like it might help. Search for FilteredClassifier. – metrix Jan 29 '14 at 19:44
  • @user75782131 If you get an example working, can you add it as an answer to helps others? – metrix Jan 29 '14 at 19:52