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 was wrong, so I can make adjustments and understand why they were incorrectly classified.
my printing method is below.
I am trying to find instances whose predicted class value was not equal to the actual value of the class, and then print its attributes.
but when I do this, listing the attributes does not print anything.
Does anyone have a suggestion on how to print inconsistent copies?
Many thanks.
private void printSummary(Classifier base, Evaluation eval, Instances data) throws Exception
{
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();
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());
}
britt source
share