title: weka - how to print incorrectly classified instances
body: <p>my weka output shows:</p>
  
  <pre><code>Correctly Classified Instances       32083               94.0244 %
  Incorrectly Classified Instances      2039                5.9756 %
  </code></pre>
  
  <p>I want to be able to print out what the incorrect instances were so i can make adjustments and understand why they were misclassified.</p>
  
  <p>my print method is below.<br>
  i am attempting to find instances whose predicted class value were not equal to the actual class value and then print its attributes.<br>
  but when i do this the attribute enumeration is not printing anything. </p>
  
  <p>Does anyone have a suggestion for how to print out the misclassified instances? </p>
  
  <p>thanks much. </p>
  
  <pre><code>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 &lt; 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());
  }
  </code></pre>