Package weka.gui.visualize

Examples of weka.gui.visualize.PlotData2D


   
    Plot2D offScreenPlot = new Plot2D();
    offScreenPlot.setSize(width, height);
   
    // master plot
    PlotData2D master = new PlotData2D(series.get(0));
    master.setPlotName(plotTitle);
    boolean[] connectPoints = new boolean[series.get(0).numInstances()];
    for (int i = 0; i < connectPoints.length; i++) {
      connectPoints[i] = true;
    }
    master.setConnectPoints(connectPoints);
    offScreenPlot.setMasterPlot(master);
    // find x and y axis
    Instances masterInstances = series.get(0);
    int xAx = getIndexOfAttribute(masterInstances, xAxis);
    int yAx = getIndexOfAttribute(masterInstances, yAxis);
    if (xAx < 0) {
      xAx = 0;
    }
    if (yAx < 0) {
      yAx = 0;
    }
   
    // plotting axes and color
    offScreenPlot.setXindex(xAx);
    offScreenPlot.setYindex(yAx);
    offScreenPlot.setCindex(masterInstances.numAttributes() - 1);
    String colorAtt = getOption(optionalArgs, "-color");
    int tempC = getIndexOfAttribute(masterInstances, colorAtt);
    if (tempC >= 0) {
      offScreenPlot.setCindex(tempC);
    }
   
    // additional plots
    if (series.size() > 1) {
      for (Instances plotI : series) {
        PlotData2D plotD = new PlotData2D(plotI);
        connectPoints = new boolean[plotI.numInstances()];
        for (int i = 0; i < connectPoints.length; i++) {
          connectPoints[i] = true;
        }
        plotD.setConnectPoints(connectPoints);
        offScreenPlot.addPlot(plotD);
      }
    }
   
    // render
View Full Code Here


   
    Plot2D offScreenPlot = new Plot2D();
    offScreenPlot.setSize(width, height);
   
    // master plot
    PlotData2D master = new PlotData2D(series.get(0));
    master.setPlotName(plotTitle);
    master.m_displayAllPoints = true;
   
    offScreenPlot.setMasterPlot(master);
   
    Instances masterInstances = series.get(0);
    int xAx = getIndexOfAttribute(masterInstances, xAxis);
    int yAx = getIndexOfAttribute(masterInstances, yAxis);
    if (xAx < 0) {
      xAx = 0;
    }
    if (yAx < 0) {
      yAx = 0;
    }
   
    // plotting axes and color
    offScreenPlot.setXindex(xAx);
    offScreenPlot.setYindex(yAx);
    offScreenPlot.setCindex(masterInstances.numAttributes() - 1);
    String colorAtt = getOption(optionalArgs, "-color");
    int tempC = getIndexOfAttribute(masterInstances, colorAtt);
    if (tempC >= 0) {
      offScreenPlot.setCindex(tempC);
    }
   
    String hasErrors = getOption(optionalArgs, "-hasErrors");
    // master plot is the error cases
    if (hasErrors != null) {
      int[] plotShapes = new int[masterInstances.numInstances()];
      for (int i = 0; i < plotShapes.length; i++) {
        plotShapes[i] = Plot2D.ERROR_SHAPE;
      }
      master.setShapeType(plotShapes);
    }
   
    // look for  an additional attribute that stores the
    // shape sizes
    String shapeSize = getOption(optionalArgs, "-shapeSize");
    if (shapeSize != null && shapeSize.length() > 0) {
      int shapeSizeI = getIndexOfAttribute(masterInstances, shapeSize);
     
      if (shapeSizeI >= 0) {
        int[] plotSizes = new int[masterInstances.numInstances()];
        for (int i = 0; i < masterInstances.numInstances(); i++) {
          plotSizes[i] = (int)masterInstances.instance(i).value(shapeSizeI);
        }
        master.setShapeSize(plotSizes);
      }
    }       
   
    // additional plots
    if (series.size() > 1) {
      for (Instances plotI : series) {
        PlotData2D plotD = new PlotData2D(plotI);
        plotD.m_displayAllPoints = true;

        offScreenPlot.addPlot(plotD);

        if (shapeSize != null && shapeSize.length() > 0) {
          int shapeSizeI = getIndexOfAttribute(plotI, shapeSize);
          if (shapeSizeI >= 0) {
            int[] plotSizes = new int[plotI.numInstances()];
            for (int i = 0; i < plotI.numInstances(); i++) {
              plotSizes[i] = (int)plotI.instance(i).value(shapeSizeI);
            }
            plotD.setShapeSize(plotSizes);
          }
        }
       
        // all other plots will have x shape if master plot are errors
        if (hasErrors != null) {
          int[] plotShapes = new int[plotI.numInstances()];
          for (int i = 0; i < plotShapes.length; i++) {
            plotShapes[i] = Plot2D.X_SHAPE;
          }
          plotD.setShapeType(plotShapes);
        }
      }
    }
   
    // render
View Full Code Here

      weka.classifiers.Classifier classifier = new weka.classifiers.bayes.NaiveBayes();
      FastVector predictions = new FastVector();
      eu.setSeed(1);
      predictions.appendElements(eu.getCVPredictions(classifier, train, 10));
      Instances result = tc.getCurve(predictions, 0);
      PlotData2D pd = new PlotData2D(result);
      pd.m_alwaysDisplayPointsOfThisSize = 10;

      boolean[] connectPoints = new boolean[result.numInstances()];
      for (int i = 1; i < connectPoints.length; i++) {
        connectPoints[i] = true;
      }
      pd.setConnectPoints(connectPoints);
      final javax.swing.JFrame jf =
        new javax.swing.JFrame("CostBenefitTest");
      jf.setSize(1000,600);
      //jf.pack();
      jf.getContentPane().setLayout(new BorderLayout());
View Full Code Here

   * @param name  the name of the plot
   * @return    the plot
   * @throws Exception  if plot generation fails
   */
  protected PlotData2D createPlotData(String name) throws Exception {
    PlotData2D   result;
   
    result = new PlotData2D(m_PlotInstances);
    if (m_PlotShapes != null)
      result.setShapeType(m_PlotShapes);
    result.addInstanceNumberAttribute();
    result.setPlotName(name + " (" + m_Instances.relationName() + ")");

    return result;
  }
View Full Code Here

       new java.io.FileReader(args[0]));
      Instances inst = new Instances(r);
      final javax.swing.JFrame jf = new javax.swing.JFrame();
      jf.getContentPane().setLayout(new java.awt.BorderLayout());
      final ModelPerformanceChart as = new ModelPerformanceChart();
      PlotData2D pd = new PlotData2D(inst);
      pd.setPlotName(inst.relationName());
      ThresholdDataEvent roc = new ThresholdDataEvent(as, pd);
      as.acceptDataSet(roc);     

      jf.getContentPane().add(as, java.awt.BorderLayout.CENTER);
      jf.addWindowListener(new java.awt.event.WindowAdapter() {
View Full Code Here

     * the threshold data.
     * @throws Exception if something goes wrong.
     */
    public synchronized void setDataSet(PlotData2D data, Attribute classAtt) throws Exception {     
      // make a copy of the PlotData2D object
      m_masterPlot = new PlotData2D(data.getPlotInstances());
      boolean[] connectPoints = new boolean[m_masterPlot.getPlotInstances().numInstances()];
      for (int i = 1; i < connectPoints.length; i++) {
        connectPoints[i] = true;
      }
      m_masterPlot.setConnectPoints(connectPoints);
View Full Code Here

      }
     
      costBenefitI.compactify();
     
      // now set up the plot data
      m_costBenefit = new PlotData2D(costBenefitI);
      m_costBenefit.m_alwaysDisplayPointsOfThisSize = 10;
      m_costBenefit.setPlotName("Cost/benefit curve");
      boolean[] connectPoints = new boolean[costBenefitI.numInstances()];
     
      for (int i = 0; i < connectPoints.length; i++) {
View Full Code Here

   * @param name  the name of the plot
   * @return    the plot or null if plot instances weren't saved for visualization
   * @throws Exception  if plot generation fails
   */
  protected PlotData2D createPlotData(String name) throws Exception {
    PlotData2D   result;
    if (!m_SaveForVisualization)
      return null;
   
    result = new PlotData2D(m_PlotInstances);
    result.setShapeSize(m_PlotSizes);
    result.setShapeType(m_PlotShapes);
    result.setPlotName(name + " (" + m_Instances.relationName() + ")");
//    result.addInstanceNumberAttribute();

    return result;
  }
View Full Code Here

        +"time. It is meant to be used if this "
        +"bean is being used programatically as as "
        +"stand alone component.");
    }
    m_visualizeDataSet = inst;
    PlotData2D pd1 = new PlotData2D(m_visualizeDataSet);
    String relationName = m_visualizeDataSet.relationName();
    pd1.setPlotName(relationName);
    try {
      m_visPanel.setMasterPlot(pd1);
    } catch (Exception ex) {
      System.err.println("Problem setting up "
       +"visualization (DataVisualizer)");
View Full Code Here

      try {
  // popup visualize panel
  if (!m_framePoppedUp) {
    m_framePoppedUp = true;
    final VisualizePanel vis = new VisualizePanel();
    PlotData2D pd1 = new PlotData2D(m_visualizeDataSet);
   
    String relationName = m_visualizeDataSet.relationName();
   
    // A bit of a nasty hack. Allows producers of instances-based
    // events to specify that the points should be connected
    if (relationName.startsWith("__")) {
      boolean[] connect = new boolean[m_visualizeDataSet.numInstances()];
      for (int i = 1; i < connect.length; i++) { connect[i] = true; }
      pd1.setConnectPoints(connect);
      relationName = relationName.substring(2);
    }
    pd1.setPlotName(relationName);
    try {
      vis.setMasterPlot(pd1);
    } catch (Exception ex) {
      System.err.println("Problem setting up "
             +"visualization (DataVisualizer)");
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.