Package weka.gui.visualize

Examples of weka.gui.visualize.PlotData2D


          textTitle);
      notifyTextListeners(te);

                  // set up visualizable errors
                  if (m_visualizableErrorListeners.size() > 0) {
                    PlotData2D errorD = new PlotData2D(m_predInstances);
                    errorD.setShapeSize(m_plotSize);
                    errorD.setShapeType(m_plotShape);
                    errorD.setPlotName(textTitle+" ("
                                       +ce.getTestSet().getDataSet().relationName()
                                       +")");
                    errorD.addInstanceNumberAttribute();
                    VisualizableErrorEvent vel =
                      new VisualizableErrorEvent(ClassifierPerformanceEvaluator.this,
                                                 errorD);
                    notifyVisualizableErrorListeners(vel);
                  }
                 

      if (ce.getTestSet().getDataSet().classAttribute().isNominal()) {
        ThresholdCurve tc = new ThresholdCurve();
        Instances result = tc.getCurve(m_eval.predictions(), 0);
        result.
          setRelationName(ce.getTestSet().getDataSet().relationName());
        PlotData2D pd = new PlotData2D(result);
        pd.setPlotName(textTitle+" ("
           +ce.getTestSet().getDataSet().
                           classAttribute().value(0)
           +")");
        boolean [] connectPoints =
          new boolean [result.numInstances()];
        for (int jj = 1; jj < connectPoints.length; jj++) {
          connectPoints[jj] = true;
        }
        pd.setConnectPoints(connectPoints);
        ThresholdDataEvent rde =
          new ThresholdDataEvent(ClassifierPerformanceEvaluator.this,
               pd);
        notifyThresholdListeners(rde);
        /*te = new TextEvent(ClassifierPerformanceEvaluator.this,
View Full Code Here


      postProcessPlotInfo(plotSize);
    }
    m_CurrentVis = new VisualizePanel();
    m_CurrentVis.setName(name+" ("+inst.relationName()+")");
    m_CurrentVis.setLog(m_Log);
    PlotData2D tempd = new PlotData2D(predInstances);
    tempd.setShapeSize(plotSize);
    tempd.setShapeType(plotShape);
    tempd.setPlotName(name+" ("+inst.relationName()+")");
    tempd.addInstanceNumberAttribute();
   
    m_CurrentVis.addPlot(tempd);
    m_CurrentVis.setColourIndex(predInstances.classIndex()+1);
     
                FastVector vv = new FastVector();
View Full Code Here

      classAssignments[(int)clusterAssignments[i]]) {
    pointShapes[i] = Plot2D.ERROR_SHAPE;
  }
      }
    }
    PlotData2D plotData = new PlotData2D(newInsts);
    if (pointShapes != null) {
      plotData.setShapeType(pointShapes);
    }
    plotData.addInstanceNumberAttribute();
    return plotData;
  }
View Full Code Here

    // Copy the current state of things
    m_Log.statusMessage("Setting up...");
    Instances inst = new Instances(m_Instances);
    inst.setClassIndex(-1);
    Instances userTest = null;
    PlotData2D predData = null;
    if (m_TestInstances != null) {
      userTest = new Instances(m_TestInstances);
    }
   
    boolean saveVis = m_StorePredictionsBut.isSelected();
    String grph = null;
    int[] ignoredAtts = null;

    int testMode = 0;
    int percent = 66;
    Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
    Clusterer fullClusterer = null;
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - "))
    .format(new Date());
    String cname = clusterer.getClass().getName();
    if (cname.startsWith("weka.clusterers.")) {
      name += cname.substring("weka.clusterers.".length());
    } else {
      name += cname;
    }
          String cmd = m_ClustererEditor.getValue().getClass().getName();
          if (m_ClustererEditor.getValue() instanceof OptionHandler)
            cmd += " " + Utils.joinOptions(((OptionHandler) m_ClustererEditor.getValue()).getOptions());
    try {
      m_Log.logMessage("Started " + cname);
      m_Log.logMessage("Command: " + cmd);
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskStarted();
      }
      if (m_PercentBut.isSelected()) {
        testMode = 2;
        percent = Integer.parseInt(m_PercentText.getText());
        if ((percent <= 0) || (percent >= 100)) {
    throw new Exception("Percentage must be between 0 and 100");
        }
      } else if (m_TrainBut.isSelected()) {
        testMode = 3;
      } else if (m_TestSplitBut.isSelected()) {
        testMode = 4;
        // Check the test instance compatibility
        if (userTest == null) {
    throw new Exception("No user test set has been opened");
        }
        if (!inst.equalHeaders(userTest)) {
    throw new Exception("Train and test set are not compatible");
        }
      } else if (m_ClassesToClustersBut.isSelected()) {
        testMode = 5;
      } else {
        throw new Exception("Unknown test mode");
      }

      Instances trainInst = new Instances(inst);
      if (m_ClassesToClustersBut.isSelected()) {
        trainInst.setClassIndex(m_ClassCombo.getSelectedIndex());
        inst.setClassIndex(m_ClassCombo.getSelectedIndex());
        if (inst.classAttribute().isNumeric()) {
    throw new Exception("Class must be nominal for class based "
            +"evaluation!");
        }
      }
      if (!m_ignoreKeyList.isSelectionEmpty()) {
        trainInst = removeIgnoreCols(trainInst);
      }

      // Output some header information
      outBuff.append("=== Run information ===\n\n");
      outBuff.append("Scheme:       " + cname);
      if (clusterer instanceof OptionHandler) {
        String [] o = ((OptionHandler) clusterer).getOptions();
        outBuff.append(" " + Utils.joinOptions(o));
      }
      outBuff.append("\n");
      outBuff.append("Relation:     " + inst.relationName() + '\n');
      outBuff.append("Instances:    " + inst.numInstances() + '\n');
      outBuff.append("Attributes:   " + inst.numAttributes() + '\n');
      if (inst.numAttributes() < 100) {
        boolean [] selected = new boolean [inst.numAttributes()];
        for (int i = 0; i < inst.numAttributes(); i++) {
    selected[i] = true;
        }
        if (!m_ignoreKeyList.isSelectionEmpty()) {
    int [] indices = m_ignoreKeyList.getSelectedIndices();
    for (int i = 0; i < indices.length; i++) {
      selected[indices[i]] = false;
    }
        }
        if (m_ClassesToClustersBut.isSelected()) {
    selected[m_ClassCombo.getSelectedIndex()] = false;
        }
        for (int i = 0; i < inst.numAttributes(); i++) {
    if (selected[i]) {
      outBuff.append("              " + inst.attribute(i).name()
         + '\n');
    }
        }
        if (!m_ignoreKeyList.isSelectionEmpty()
      || m_ClassesToClustersBut.isSelected()) {
    outBuff.append("Ignored:\n");
    for (int i = 0; i < inst.numAttributes(); i++) {
      if (!selected[i]) {
        outBuff.append("              " + inst.attribute(i).name()
           + '\n');
      }
    }
        }
      } else {
        outBuff.append("              [list of attributes omitted]\n");
      }

      if (!m_ignoreKeyList.isSelectionEmpty()) {
        ignoredAtts = m_ignoreKeyList.getSelectedIndices();
      }

      if (m_ClassesToClustersBut.isSelected()) {
        // add class to ignored list
        if (ignoredAtts == null) {
    ignoredAtts = new int[1];
    ignoredAtts[0] = m_ClassCombo.getSelectedIndex();
        } else {
    int[] newIgnoredAtts = new int[ignoredAtts.length+1];
    System.arraycopy(ignoredAtts, 0, newIgnoredAtts, 0, ignoredAtts.length);
    newIgnoredAtts[ignoredAtts.length] = m_ClassCombo.getSelectedIndex();
    ignoredAtts = newIgnoredAtts;
        }
      }


      outBuff.append("Test mode:    ");
      switch (testMode) {
        case 3: // Test on training
        outBuff.append("evaluate on training data\n");
        break;
        case 2: // Percent split
        outBuff.append("split " + percent
             + "% train, remainder test\n");
        break;
        case 4: // Test on user split
        outBuff.append("user supplied test set: "
           + userTest.numInstances() + " instances\n");
        break;
      case 5: // Classes to clusters evaluation on training
        outBuff.append("Classes to clusters evaluation on training data");
       
        break;
      }
      outBuff.append("\n");
      m_History.addResult(name, outBuff);
      m_History.setSingle(name);
     
      // Build the model and output it.
      m_Log.statusMessage("Building model on training data...");

      // remove the class attribute (if set) and build the clusterer
      clusterer.buildClusterer(removeClass(trainInst));
     
      if (testMode == 2) {
        outBuff.append("\n=== Clustering model (full training set) ===\n\n");
     
        outBuff.append(clusterer.toString() + '\n');
      }
      m_History.updateResult(name);
      if (clusterer instanceof Drawable) {
        try {
    grph = ((Drawable)clusterer).graph();
        } catch (Exception ex) {
        }
      }
      // copy full model for output
      SerializedObject so = new SerializedObject(clusterer);
      fullClusterer = (Clusterer) so.getObject();
     
      ClusterEvaluation eval = new ClusterEvaluation();
      eval.setClusterer(clusterer);
      switch (testMode) {
        case 3: case 5: // Test on training
        m_Log.statusMessage("Clustering training data...");
        eval.evaluateClusterer(trainInst);
        predData = setUpVisualizableInstances(inst,eval);
        outBuff.append("=== Model and evaluation on training set ===\n\n");
        break;

        case 2: // Percent split
        m_Log.statusMessage("Randomizing instances...");
        inst.randomize(new Random(1));
        trainInst.randomize(new Random(1));
        int trainSize = trainInst.numInstances() * percent / 100;
        int testSize = trainInst.numInstances() - trainSize;
        Instances train = new Instances(trainInst, 0, trainSize);
        Instances test = new Instances(trainInst, trainSize, testSize);
        Instances testVis = new Instances(inst, trainSize, testSize);
        m_Log.statusMessage("Building model on training split...");
        clusterer.buildClusterer(train);
        m_Log.statusMessage("Evaluating on test split...");
        eval.evaluateClusterer(test);
        predData = setUpVisualizableInstances(testVis, eval);
        outBuff.append("=== Model and evaluation on test split ===\n");
        break;
   
        case 4: // Test on user split
        m_Log.statusMessage("Evaluating on test data...");
        Instances userTestT = new Instances(userTest);
        if (!m_ignoreKeyList.isSelectionEmpty()) {
    userTestT = removeIgnoreCols(userTestT);
        }
        eval.evaluateClusterer(userTestT);
        predData = setUpVisualizableInstances(userTest, eval);
        outBuff.append("=== Model and evaluation on test set ===\n");
        break;

        default:
        throw new Exception("Test mode not implemented");
      }
      outBuff.append(eval.clusterResultsToString());
      outBuff.append("\n");
      m_History.updateResult(name);
      m_Log.logMessage("Finished " + cname);
      m_Log.statusMessage("OK");
    } catch (Exception ex) {
      ex.printStackTrace();
      m_Log.logMessage(ex.getMessage());
      JOptionPane.showMessageDialog(ClustererPanel.this,
            "Problem evaluating clusterer:\n"
            + ex.getMessage(),
            "Evaluate clusterer",
            JOptionPane.ERROR_MESSAGE);
      m_Log.statusMessage("Problem evaluating clusterer");
    } finally {
      if (predData != null) {
        m_CurrentVis = new VisualizePanel();
        m_CurrentVis.setName(name+" ("+inst.relationName()+")");
        m_CurrentVis.setLog(m_Log);
        predData.setPlotName(name+" ("+inst.relationName()+")");
       
        try {
    m_CurrentVis.addPlot(predData);
        } catch (Exception ex) {
    System.err.println(ex);
View Full Code Here

            m_Log.statusMessage("Setting up...");

            StringBuffer outBuff = m_History.getNamedBuffer(name);
            Instances userTest = null;

            PlotData2D predData = null;
            if (m_TestInstances != null) {
              userTest = new Instances(m_TestInstances);
            }
   
            boolean saveVis = m_StorePredictionsBut.isSelected();
            String grph = null;

            try {
              if (userTest == null) {
                throw new Exception("No user test set has been opened");
              }
              if (trainHeader != null && !trainHeader.equalHeaders(userTest)) {
                throw new Exception("Train and test set are not compatible");
              }

              m_Log.statusMessage("Evaluating on test data...");
              m_Log.logMessage("Re-evaluating clusterer (" + name + ") on test set");

              m_Log.logMessage("Started reevaluate model");
              if (m_Log instanceof TaskLogger) {
                ((TaskLogger)m_Log).taskStarted();
              }
              ClusterEvaluation eval = new ClusterEvaluation();
              eval.setClusterer(clusterer);
   
              Instances userTestT = new Instances(userTest);
              if (ignoredAtts != null) {
                userTestT = removeIgnoreCols(userTestT, ignoredAtts);
              }

              eval.evaluateClusterer(userTestT);
     
              predData = setUpVisualizableInstances(userTest, eval);

              outBuff.append("\n=== Re-evaluation on test set ===\n\n");
              outBuff.append("User supplied test set\n")
              outBuff.append("Relation:     " + userTest.relationName() + '\n');
              outBuff.append("Instances:    " + userTest.numInstances() + '\n');
              outBuff.append("Attributes:   " + userTest.numAttributes() + "\n\n");
              if (trainHeader == null)
                outBuff.append("NOTE - if test set is not compatible then results are "
                               + "unpredictable\n\n");
     
              outBuff.append(eval.clusterResultsToString());
              outBuff.append("\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());
              JOptionPane.showMessageDialog(ClustererPanel.this,
                                            "Problem evaluating clusterer:\n"
                                            + ex.getMessage(),
                                            "Evaluate clusterer",
                                            JOptionPane.ERROR_MESSAGE);
              m_Log.statusMessage("Problem evaluating clusterer");

            } finally {
              if (predData != null) {
                m_CurrentVis = new VisualizePanel();
                m_CurrentVis.setName(name+" ("+userTest.relationName()+")");
                m_CurrentVis.setLog(m_Log);
                predData.setPlotName(name+" ("+userTest.relationName()+")");
 
                try {
                  m_CurrentVis.addPlot(predData);
                } catch (Exception ex) {
                  System.err.println(ex);
View Full Code Here

        MarginCurve tc = new MarginCurve();
        Instances result = tc.getCurve(preds);
        VisualizePanel vmc = new VisualizePanel();
        vmc.setName(result.relationName());
        vmc.setLog(m_Log);
        PlotData2D tempd = new PlotData2D(result);
        tempd.setPlotName(result.relationName());
        tempd.addInstanceNumberAttribute();
        vmc.addPlot(tempd);
        visualizeClassifierErrors(vmc);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  });
    } else {
      visMargin.setEnabled(false);
    }
    resultListMenu.add(visMargin);

    JMenu visThreshold = new JMenu("Visualize threshold curve");
    if (preds != null && classAtt != null) {
      for (int i = 0; i < classAtt.numValues(); i++) {
  JMenuItem clv = new JMenuItem(classAtt.value(i));
  final int classValue = i;
  clv.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
    ThresholdCurve tc = new ThresholdCurve();
    Instances result = tc.getCurve(preds, classValue);
    //VisualizePanel vmc = new VisualizePanel();
    ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
    vmc.setROCString("(Area under ROC = " +
         Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
    vmc.setLog(m_Log);
    vmc.setName(result.relationName()+". (Class value "+
          classAtt.value(classValue)+")");
    PlotData2D tempd = new PlotData2D(result);
    tempd.setPlotName(result.relationName());
    tempd.addInstanceNumberAttribute();
    vmc.addPlot(tempd);
    visualizeClassifierErrors(vmc);
        } catch (Exception ex) {
    ex.printStackTrace();
        }
        }
    });
    visThreshold.add(clv);
      }
    } else {
      visThreshold.setEnabled(false);
    }
    resultListMenu.add(visThreshold);

    JMenu visCost = new JMenu("Visualize cost curve");
    if (preds != null && classAtt != null) {
      for (int i = 0; i < classAtt.numValues(); i++) {
  JMenuItem clv = new JMenuItem(classAtt.value(i));
  final int classValue = i;
  clv.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
    CostCurve cc = new CostCurve();
    Instances result = cc.getCurve(preds, classValue);
    VisualizePanel vmc = new VisualizePanel();
    vmc.setLog(m_Log);
    vmc.setName(result.relationName()+". (Class value "+
          classAtt.value(classValue)+")");
    PlotData2D tempd = new PlotData2D(result);
    tempd.m_displayAllPoints = true;
    tempd.setPlotName(result.relationName());
    boolean [] connectPoints =
      new boolean [result.numInstances()];
    for (int jj = 1; jj < connectPoints.length; jj+=2) {
      connectPoints[jj] = true;
    }
    tempd.setConnectPoints(connectPoints);
    //      tempd.addInstanceNumberAttribute();
    vmc.addPlot(tempd);
    visualizeClassifierErrors(vmc);
        } catch (Exception ex) {
    ex.printStackTrace();
View Full Code Here

                  }
                  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) {
View Full Code Here

          System.err.println("Loading instances from " + filename);
          try {
            Reader r = new java.io.BufferedReader(new FileReader(filename));
            Instances i = new Instances(r);
            i.setClassIndex(i.numAttributes()-1);
            PlotData2D pd1 = new PlotData2D(i);

            if (j == 0) {
              pd1.setPlotName("Master plot");
              panel.setMasterPlot(pd1);
            } else {
              pd1.setPlotName("Plot "+(j+1));
              pd1.m_useCustomColour = true;
              pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
              panel.addPlot(pd1);
            }
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
                m_Self, "Error loading file '" + files[j] + "':\n" + ex.getMessage());
            return;
          }
        }

        // create frame
        final JFrame frame = new JFrame("Plot - " + filenames);
        frame.setIconImage(m_Icon);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(panel, BorderLayout.CENTER);
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            m_Plots.remove(frame);
            frame.dispose();
            checkExit();
          }
        });
        frame.pack();
        frame.setSize(800, 600);
        frame.setVisible(true);
        m_Plots.add(frame);
      }
    });
   
    // Visualization/ROC
    JMenuItem jMenuItemVisualizationROC = new JMenuItem();
    m_jMenuVisualization.add(jMenuItemVisualizationROC);
    jMenuItemVisualizationROC.setText("ROC");
    // jMenuItemVisualizationROC.setMnemonic('R');
    jMenuItemVisualizationROC.
      setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK));
   
    jMenuItemVisualizationROC.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // choose file
        int retVal = m_FileChooserROC.showOpenDialog(m_Self);
        if (retVal != JFileChooser.APPROVE_OPTION)
          return;

        // create plot
        String filename  = m_FileChooserROC.getSelectedFile().getAbsolutePath();
        Instances result = null;
        try {
          result = new Instances(new BufferedReader(new FileReader(filename)));
        }
        catch (Exception ex) {
          ex.printStackTrace();
          JOptionPane.showMessageDialog(
              m_Self, "Error loading file '" + filename + "':\n" + ex.getMessage());
          return;
        }
        result.setClassIndex(result.numAttributes() - 1);
        ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
        vmc.setROCString("(Area under ROC = " +
            Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
        vmc.setName(result.relationName());
        PlotData2D tempd = new PlotData2D(result);
        tempd.setPlotName(result.relationName());
        tempd.addInstanceNumberAttribute();
        try {
          vmc.addPlot(tempd);
        }
        catch (Exception ex) {
          ex.printStackTrace();
View Full Code Here

      System.err.println("Loading instances from " + filename);
      try {
        Reader r = new java.io.BufferedReader(new FileReader(filename));
        Instances i = new Instances(r);
        i.setClassIndex(i.numAttributes()-1);
        PlotData2D pd1 = new PlotData2D(i);

        if (j == 0) {
    pd1.setPlotName("Master plot");
    panel.setMasterPlot(pd1);
        } else {
    pd1.setPlotName("Plot "+(j+1));
    pd1.m_useCustomColour = true;
    pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
    panel.addPlot(pd1);
        }
      }
      catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(
      m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
        return;
      }
    }

    // create frame
    createFrame(
        m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames,
        panel, new BorderLayout(),
        BorderLayout.CENTER, 800, 600, null, true, true);
  }
      });

      // Visualization/ROC
      // based on this Wiki article:
      // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
      jMenuItemVisualizationROC = new JMenuItem();
      jMenuVisualization.add(jMenuItemVisualizationROC);
      jMenuItemVisualizationROC.setText("ROC");
      jMenuItemVisualizationROC.setMnemonic('R');
      jMenuItemVisualizationROC.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    // choose file
    int retVal = m_FileChooserROC.showOpenDialog(m_Self);
    if (retVal != JFileChooser.APPROVE_OPTION)
      return;

    // create plot
    String filename  = m_FileChooserROC.getSelectedFile().getAbsolutePath();
    Instances result = null;
    try {
      result = new Instances(new BufferedReader(new FileReader(filename)));
    }
    catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(
    m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
      return;
    }
    result.setClassIndex(result.numAttributes() - 1);
    ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
    vmc.setROCString("(Area under ROC = " +
        Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
    vmc.setName(result.relationName());
    PlotData2D tempd = new PlotData2D(result);
    tempd.setPlotName(result.relationName());
    tempd.addInstanceNumberAttribute();
    try {
      vmc.addPlot(tempd);
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

              textTitle);
        notifyTextListeners(te);

        // set up visualizable errors
        if (m_visualizableErrorListeners.size() > 0) {
          PlotData2D errorD = new PlotData2D(m_aggregatedPlotInstances);
          errorD.setShapeSize(m_aggregatedPlotSizes);
          errorD.setShapeType(m_aggregatedPlotShapes);
          errorD.setPlotName(textTitle + " " + textOptions);
         
/*          PlotData2D errorD = m_PlotInstances.getPlotData(
              textTitle + " " + textOptions); */
          VisualizableErrorEvent vel =
            new VisualizableErrorEvent(ClassifierPerformanceEvaluator.this, errorD);
          notifyVisualizableErrorListeners(vel);
          m_PlotInstances.cleanUp();
        }


        if (testData.classAttribute().isNominal() &&
            m_thresholdListeners.size() > 0) {
          ThresholdCurve tc = new ThresholdCurve();
          Instances result = tc.getCurve(m_eval.predictions(), 0);
          result.
          setRelationName(testData.relationName());
          PlotData2D pd = new PlotData2D(result);
          String htmlTitle = "<html><font size=-2>"
            + textTitle;
          String newOptions = "";
          if (classifier instanceof OptionHandler) {
            String[] options =
              ((OptionHandler) classifier).getOptions();
            if (options.length > 0) {
              for (int ii = 0; ii < options.length; ii++) {
                if (options[ii].length() == 0) {
                  continue;
                }
                if (options[ii].charAt(0) == '-' &&
                    !(options[ii].charAt(1) >= '0' &&
                        options[ii].charAt(1)<= '9')) {
                  newOptions += "<br>";
                }
                newOptions += options[ii];
              }
            }
          }

          htmlTitle += " " + newOptions + "<br>"
          + " (class: "
          + testData.classAttribute().value(0) + ")"
          + "</font></html>";
          pd.setPlotName(textTitle + " (class: "
              + testData.classAttribute().value(0) + ")");
          pd.setPlotNameHTML(htmlTitle);
          boolean [] connectPoints =
            new boolean [result.numInstances()];
          for (int jj = 1; jj < connectPoints.length; jj++) {
            connectPoints[jj] = true;
          }

          pd.setConnectPoints(connectPoints);

          ThresholdDataEvent rde =
            new ThresholdDataEvent(ClassifierPerformanceEvaluator.this,
                pd, testData.classAttribute());
          notifyThresholdListeners(rde);
View Full Code Here

TOP

Related Classes of weka.gui.visualize.PlotData2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.