outBuff.append("Instances:    " + userTestStructure.numInstances() + "\n");
outBuff.append("Instances:    " + source.getDataSet().numInstances() + "\n");
          public void run() {            // Copy the current state of things            m_Log.statusMessage("Setting up...");            StringBuffer outBuff = m_History.getNamedBuffer(name);            DataSource source = null;            Instances userTestStructure = null;            // additional vis info (either shape type or point size)            FastVector plotShape = new FastVector();            FastVector plotSize = new FastVector();            Instances predInstances = null;            CostMatrix costMatrix = null;            if (m_EvalWRTCostsBut.isSelected()) {              costMatrix = new CostMatrix((CostMatrix) m_CostMatrixEditor                                          .getValue());            }                boolean outputConfusion = m_OutputConfusionBut.isSelected();            boolean outputPerClass = m_OutputPerClassBut.isSelected();            boolean outputSummary = true;            boolean outputEntropy = m_OutputEntropyBut.isSelected();            boolean saveVis = m_StorePredictionsBut.isSelected();            boolean outputPredictionsText =               m_OutputPredictionsTextBut.isSelected();            String grph = null;                Evaluation eval = null;            try {              boolean incrementalLoader = (m_TestLoader instanceof IncrementalConverter);              if (m_TestLoader != null && m_TestLoader.getStructure() != null) {                m_TestLoader.reset();                source = new DataSource(m_TestLoader);                userTestStructure = source.getStructure();              }              // Check the test instance compatibility              if (source == null) {                throw new Exception("No user test set has been specified");              }              if (trainHeader != null) {                if (trainHeader.classIndex() >                     userTestStructure.numAttributes()-1)                  throw new Exception("Train and test set are not compatible");                userTestStructure.setClassIndex(trainHeader.classIndex());                if (!trainHeader.equalHeaders(userTestStructure)) {                  throw new Exception("Train and test set are not compatible");                }              } else {                userTestStructure.                  setClassIndex(userTestStructure.numAttributes()-1);              }              if (m_Log instanceof TaskLogger) {                ((TaskLogger)m_Log).taskStarted();              }              m_Log.statusMessage("Evaluating on test data...");              m_Log.logMessage("Re-evaluating classifier (" + name                                + ") on test set");              eval = new Evaluation(userTestStructure, costMatrix);              eval.useNoPriors();                    // set up the structure of the plottable instances for               // visualization              predInstances = setUpVisualizableInstances(userTestStructure);              predInstances.setClassIndex(userTestStructure.classIndex()+1);                    outBuff.append("\n=== Re-evaluation on test set ===\n\n");              outBuff.append("User supplied test set\n");                outBuff.append("Relation:     "                              + userTestStructure.relationName() + '\n');              if (incrementalLoader)        	outBuff.append("Instances:     unknown (yet). Reading incrementally\n");              else        	outBuff.append("Instances:    " + userTestStructure.numInstances() + "\n");              outBuff.append("Attributes:   "         	  + userTestStructure.numAttributes()         	  + "\n\n");              if (trainHeader == null)                outBuff.append("NOTE - if test set is not compatible then results are "                               + "unpredictable\n\n");              if (outputPredictionsText) {                outBuff.append("=== Predictions on test set ===\n\n");                outBuff.append(" inst#,    actual, predicted, error");                if (userTestStructure.classAttribute().isNominal()) {                  outBuff.append(", probability distribution");                }                outBuff.append("\n");              }	      Instance instance;	      int jj = 0;	      while (source.hasMoreElements()) {		instance = source.nextElement();		instance.setDataset(userTestStructure);		processClassifierPrediction(instance, classifier,		    eval, predInstances, plotShape,		    plotSize);		if (outputPredictionsText) { 		  outBuff.append(predictionText(classifier, instance, jj+1));		}		if ((++jj % 100) == 0) {		  m_Log.statusMessage("Evaluating on test data. Processed "		      +jj+" instances...");		}	      }              if (outputPredictionsText) {                outBuff.append("\n");              }                     if (outputSummary) {                outBuff.append(eval.toSummaryString(outputEntropy) + "\n");              }                    if (userTestStructure.classAttribute().isNominal()) {	                if (outputPerClass) {                  outBuff.append(eval.toClassDetailsString() + "\n");                }	                if (outputConfusion) {                  outBuff.append(eval.toMatrixString() + "\n");                }              }                    m_History.updateResult(name);              m_Log.logMessage("Finished re-evaluation");              m_Log.statusMessage("OK");            } catch (Exception ex) {              ex.printStackTrace();              m_Log.logMessage(ex.getMessage());              m_Log.statusMessage("See error log");              ex.printStackTrace();              m_Log.logMessage(ex.getMessage());              JOptionPane.showMessageDialog(ClassifierPanel.this,                                            "Problem evaluationg classifier:\n"                                            + ex.getMessage(),                                            "Evaluate classifier",                                            JOptionPane.ERROR_MESSAGE);              m_Log.statusMessage("Problem evaluating classifier");            } finally {              try {                if (predInstances != null && predInstances.numInstances() > 0) {                  if (predInstances.attribute(predInstances.classIndex())                      .isNumeric()) {                    postProcessPlotInfo(plotSize);                  }                  m_CurrentVis = new VisualizePanel();                  m_CurrentVis.setName(name+" ("                                       +userTestStructure.relationName()+")");                  m_CurrentVis.setLog(m_Log);                  PlotData2D tempd = new PlotData2D(predInstances);                  tempd.setShapeSize(plotSize);                  tempd.setShapeType(plotShape);                  tempd.setPlotName(name+" ("+userTestStructure.relationName()                                    +")");                  tempd.addInstanceNumberAttribute();	                    m_CurrentVis.addPlot(tempd);                  m_CurrentVis.setColourIndex(predInstances.classIndex()+1);	                    if (classifier instanceof Drawable) {                    try {                      grph = ((Drawable)classifier).graph();                    } catch (Exception ex) {                    }                  }                  if (saveVis) {                    FastVector vv = new FastVector();                    vv.addElement(classifier);                    if (trainHeader != null) vv.addElement(trainHeader);                    vv.addElement(m_CurrentVis);                    if (grph != null) {                      vv.addElement(grph);                    }                    if ((eval != null) && (eval.predictions() != null)) {                      vv.addElement(eval.predictions());                      vv.addElement(userTestStructure.classAttribute());                    }                    m_History.addObject(name, vv);                  } else {                    FastVector vv = new FastVector();                    vv.addElement(classifier);                    if (trainHeader != null) vv.addElement(trainHeader);                    m_History.addObject(name, vv);                  }                }              } catch (Exception ex) {                ex.printStackTrace();              }              if (isInterrupted()) {                m_Log.logMessage("Interrupted reevaluate model");                m_Log.statusMessage("Interrupted");              }              synchronized (this) {                m_StartBut.setEnabled(true);                m_StopBut.setEnabled(false);                m_RunThread = null;              }              if (m_Log instanceof TaskLogger) {                ((TaskLogger)m_Log).taskFinished();              }            }          }