0
votes

I wrote a custom classifier for WEKA, and it needs to provide information besides just a predicted class for an instance. Specifically, it is a list describing how great the effect of each of a subset of the training instances was on the predicted class.

The additionalMeasureProducer interface will not work, since I need to print a string to the GUI. I would like the user to be able to choose to output this information. I had hoped that the option "Output model" in the "Classifier evaluation options" dialog box would do the trick, but WEKA ends up calling my classifier's toString() method before classification has happened. I consider this a bug, since my classifier is in the weka.classifiers.lazy package, meaning that it isn't built until the Instance to be classified is given to it.

Does anyone have any idea how to add more GUI output capabilities to a custom WEKA classifier?

1
This seems to be quite a specialized Weka question. You might also want to ask it on the Weka mailing list: list.scms.waikato.ac.nz/mailman/listinfo/wekalist - Sicco

1 Answers

2
votes

Well, the only way I could find to do this properly was to implement a special weka.classifiers.evaluation.output.prediction.AbstractOutput which could only be used with my classifier. I specified it with globalInfo(), and getDisplay(), and my doPrintClassification method starts like this:

@Override
protected void doPrintClassification(Classifier classifier, Instance inst,
        int index) throws Exception {
    if (!(classifier instanceof MyClassifier))
        throw new IllegalArgumentException(
                "This output can only be used with the MyClassifier classifier");

    MyClassifier mc = (MyClassifier) classifier;

That way I was able to call the proper methods to get the information for my classifier. Writing it all for CSV, HTML and plaintext was too much, so I just leave it to the user's choice to get special information from my custom output class and get regular information from the other output classes if they desire a specific format.