javacommentswekaarff

Add comment to an ARFF file


this is my first question in this forum.... I'm making adata-mining application in java with the WEKA API. I make first a pre-processing stage and when I save the ARFF file i would like to add a couple of lines (as comments) specifing the preprocessing task that i have done to the file... the problem is that i don't know how to add comments to an ARFF file from the java WEKA API. To save the file i use the class ArffSaver like this...

    try {
        ArffSaver saver = new ArffSaver();
        saver.setInstances(dataPost);
        saver.setFile(arffFile);
        saver.writeBatch();
        return true;
    } catch (IOException ex) {
        Logger.getLogger(Preprocesamiento.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }

I would be really greatfull if someone could give some idea... thanks!


Solution

  • You should AVOID writting comments on an .arff file, even more when writting it from Java. These files are very "parser-sensitive". The Weka API to create these files is restrictive for this particular reason.

    Even though, you can always add your comments manually with the % symbol. This said, I wouldn't recommend you writting anything more than instances, attributes and values into an .arff file. ;-)