my weka output shows:
Correctly Classified Instances       32083               94.0244 %
Incorrectly Classified Instances      2039                5.9756 %
I want to be able to print out what the incorrect instances were so i can make adjustments and understand why they were misclassified.
my print method is below.
i am attempting to find instances whose predicted class value were not equal to the actual class value and then print its attributes.
but when i do this the attribute enumeration is not printing anything. 
Does anyone have a suggestion for how to print out the misclassified instances?
thanks much.
private void printSummary(Classifier base, Evaluation eval, Instances data) throws Exception
{
    // output evaluation
    System.out.println();
    System.out.println("=== Setup ===");
    System.out.println("Classifier: " + classifierName.getClass().getName() + " " + Utils.joinOptions(base.getOptions()));
    System.out.println("Dataset: " + data.relationName());
    System.out.println();
    // output predictions
    System.out.println("# - actual - predicted - error - distribution - token");
    for (int i = 0; i < data.numInstances(); i++) 
    {
        double pred = base.classifyInstance(data.instance(i));
        double actual = data.instance(i).classValue();
        double[] dist = base.distributionForInstance(data.instance(i));
        if (pred != actual)
        {
            System.out.print((i+1));
            System.out.print(" - ");
            System.out.print(data.instance(i).toString(data.classIndex()));
            System.out.print(" - ");
            System.out.print(data.classAttribute().value((int) pred));
            System.out.print(" - ");
            if (pred != data.instance(i).classValue())
                System.out.print("yes");
            else
                System.out.print("no");
            System.out.print(" - ");
            System.out.print(Utils.arrayToString(dist));
            System.out.print(" - ");
            data.instance(i).enumerateAttributes().toString();
            System.out.println();
        }
    }
    System.out.println(eval.toSummaryString());
    System.out.println(eval.toClassDetailsString());
    System.out.println(eval.toMatrixString());
}
I do this that way:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With