11

I've trained a classifier in Weka, and I'm able to use it on test data. Additionally, I can opt to display the classifier's predictions in the log window for this test data.

However, for my current project, it would be convenient for me to be able to get this data in CSV format. Is this possible in Weka ? Is it only possible when using the command line (something I'll eventually move towards) ?

I could always save the entire buffer result to a text file, but in that case, I would have to parse the file and remove all the "noise" (which isn't really noise, but you get the point).

So, to conclude, is there any way to output Weka's predictions for a test set to a CSV file ?

Edit: as the answer below shows, there is an option to do this. However, it can only be found in Weka 3.7 and above !

elliottbolzan
  • 1,057
  • 1
  • 15
  • 30
  • Did my post answer your question? – Sicco Nov 02 '12 at 13:26
  • I'm very sorry, but because of Hurricane Sandy, I haven't had access to my computer. However, I'm pretty sure my version of Weka, the latest, doesn't have the option to output to CSV where you described. Is this possible ? Have the options potentially moved around ? – elliottbolzan Nov 02 '12 at 18:19
  • 2
    I think I found the problem. Are you using Weka 3.6.x? That version indeed doesn't have the described output option. The 3.7.x version of Weka does support this output though, so you might want to download and use that version. All the best with recovering from Sandy. – Sicco Nov 02 '12 at 22:48
  • 1
    Is there any way one can do this from the command line? I.e. how does one run a classifier and save the results to a csv file, from the command line? – Astrid Jan 28 '14 at 22:37
  • @Astrid CSV file from command line here: http://stackoverflow.com/questions/17645433/weka-predictions-to-csv-from-command-line/ – metrix May 07 '14 at 19:36

3 Answers3

18

I assume you use Weka's Explorer. In the Classify tab click on More options..., then click on Output predictions and select CSV. Now click on the box showing CSV and a window opens where you can fill in the properties of writing to a CSV file. Click on outputFile and select a folder and type a filename (note: you must supply a filename). Running a new test will now save the prediction results to your CSV file.

Sicco
  • 6,167
  • 5
  • 45
  • 61
  • Thank you! The official documentation never mentioned the part where one can actually _find_ the predictions. –  Jan 26 '14 at 17:41
6

In Weka 3.6.x you can right-click your model, choose "Visualize classifier errors" and Save the data (including the prediction) from there.

Michal Illich
  • 1,835
  • 1
  • 14
  • 10
1

If you use weka knowledge flow to build models (Easier than explorer), there are CSV data sinks you can use to save as CSV file.

Haja Maideen
  • 450
  • 2
  • 4