List of usage examples for weka.gui.visualize PlotData2D PlotData2D
public PlotData2D(Instances insts)
From source file:cyber009.main.UDAL.java
public void showData() { List<Attribute> atts = new ArrayList<>(); Attribute[] att = new Attribute[v.N + 2]; for (int i = 0; i <= v.N; i++) { att[i] = new Attribute("X" + i); atts.add(att[i]);/*from w ww. j a va 2s. c om*/ } List<String> classValus = new ArrayList<>(); classValus.add("1.0"); classValus.add("0.0"); att[v.N + 1] = new Attribute("class", classValus); atts.add(att[v.N + 1]); Instances dataSet = new Instances("Syn Data", (ArrayList<Attribute>) atts, v.D); for (int d = 0; d < v.D; d++) { Instance ins = new DenseInstance(v.N + 2); for (int i = 0; i <= v.N; i++) { ins.setValue(atts.get(i), v.X[d][i]); } ins.setValue(atts.get(v.N + 1), v.TARGET[d]); dataSet.add(ins); } //System.out.println(dataSet); PlotData2D p2D = new PlotData2D(dataSet); p2D.setPlotName("Syn data"); VisualizePanel vp = new VisualizePanel(); vp.setName("Show Data"); try { vp.addPlot(p2D); JFrame frame = new JFrame("Show Data"); frame.setSize(600, 600); frame.setVisible(true); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(vp, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); func.showCoefficients(); } catch (Exception ex) { Logger.getLogger(MainSyntacticData.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cyber009.main.UDALNeuralNetwork.java
public void showData() { //System.out.println(dataSet); PlotData2D p2D = new PlotData2D(dataSet); p2D.setPlotName("Syn data"); VisualizePanel vp = new VisualizePanel(); vp.setName("Show Data"); try {//from ww w.ja va2s . c o m vp.addPlot(p2D); JFrame frame = new JFrame("Show Data"); frame.setSize(600, 600); frame.setVisible(true); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(vp, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); func.showCoefficients(); } catch (Exception ex) { Logger.getLogger(MainSyntacticData.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cyber009.udal.mains.WekaUDAL.java
public void showPlot(Instances dataSet) { PlotData2D p2D = new PlotData2D(dataSet); p2D.setPlotName(dataSet.relationName()); VisualizePanel vp = new VisualizePanel(); vp.setName(dataSet.relationName());/*from ww w . ja va 2s . c o m*/ try { vp.addPlot(p2D); JFrame frame = new JFrame(dataSet.relationName()); frame.setSize(600, 600); frame.setVisible(true); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(vp, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } catch (Exception ex) { Logger.getLogger(WekaUDAL.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:meka.gui.explorer.classify.AbstractShowThresholdCurve.java
License:Open Source License
/** * Creates a panel displaying the ROC data. * * @param data the threshold curve data * @param title the title of the plot * @return the panel/*from w w w.j a va2s . co m*/ * @throws Exception if plot generation fails */ protected ThresholdVisualizePanel createPanel(Instances data, String title) throws Exception { ThresholdVisualizePanel result = new ThresholdVisualizePanel(); PlotData2D plot = new PlotData2D(data); plot.setPlotName(title); plot.m_displayAllPoints = true; boolean[] connectPoints = new boolean[data.numInstances()]; for (int cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); result.addPlot(plot); setComboBoxIndices(data, result); return result; }
From source file:meka.gui.explorer.classify.IncrementalPerformance.java
License:Open Source License
/** * Creates a panel displaying the data.//ww w . ja v a 2s . c o m * * @param data the plot data * @return the panel * @throws Exception if plot generation fails */ protected VisualizePanel createPanel(Instances data) throws Exception { VisualizePanel result = new ThresholdVisualizePanel(); PlotData2D plot = new PlotData2D(data); plot.setPlotName("Incremental performance"); plot.m_displayAllPoints = true; boolean[] connectPoints = new boolean[data.numInstances()]; for (int cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); result.addPlot(plot); if (data.attribute(SAMPLES) != null) result.setXIndex(data.attribute(SAMPLES).index()); if (data.attribute(ACCURACY) != null) result.setYIndex(data.attribute(ACCURACY).index()); return result; }
From source file:meka.gui.explorer.classify.ShowMacroCurve.java
License:Open Source License
/** * Creates a panel displaying the data.//from w w w .jav a 2 s . co m * * @param data the plot data * @return the panel * @throws Exception if plot generation fails */ protected VisualizePanel createPanel(Instances data) throws Exception { VisualizePanel result = new ThresholdVisualizePanel(); PlotData2D plot = new PlotData2D(data); plot.setPlotName("Macro-averaged Performance"); plot.m_displayAllPoints = true; boolean[] connectPoints = new boolean[data.numInstances()]; for (int cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); result.addPlot(plot); if (data.attribute(SAMPLES) != null) result.setXIndex(data.attribute(SAMPLES).index()); if (data.attribute(ACCURACY) != null) result.setYIndex(data.attribute(ACCURACY).index()); return result; }
From source file:meka.gui.explorer.classify.ShowMicroCurve.java
License:Open Source License
/** * Creates a panel displaying the data.//ww w. j a va2 s . com * * @param data the plot data * @return the panel * @throws Exception if plot generation fails */ protected VisualizePanel createPanel(Instances data) throws Exception { VisualizePanel result = new ThresholdVisualizePanel(); PlotData2D plot = new PlotData2D(data); plot.setPlotName("Micro-averaged Performance"); plot.m_displayAllPoints = true; boolean[] connectPoints = new boolean[data.numInstances()]; for (int cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); result.addPlot(plot); if (data.attribute(SAMPLES) != null) result.setXIndex(data.attribute(SAMPLES).index()); if (data.attribute(ACCURACY) != null) result.setYIndex(data.attribute(ACCURACY).index()); return result; }
From source file:meka.gui.guichooser.PrecisionRecallCurve.java
License:Open Source License
/** * Called by the menu items action listener. *//* w w w. j a v a 2s .c om*/ @Override protected void launch() { m_FileChooser = GUIHelper.newConverterFileChooser(); // choose file int retVal = m_FileChooser.showOpenDialog(null); if (retVal != JFileChooser.APPROVE_OPTION) return; File file = m_FileChooser.getSelectedFile(); // create plot Instances data; try { data = m_FileChooser.getLoader().getDataSet(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error loading file '" + file + "':\n" + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); return; } data.setClassIndex(data.numAttributes() - 1); ThresholdVisualizePanel vmc = new ThresholdVisualizePanel(); vmc.setROCString("(Area under PRC = " + Utils.doubleToString(ThresholdCurve.getPRCArea(data), 4) + ")"); vmc.setName(data.relationName()); PlotData2D tempd = new PlotData2D(data); tempd.setPlotName(data.relationName()); tempd.m_displayAllPoints = true; // specify which points are connected boolean[] cp = new boolean[data.numInstances()]; for (int n = 1; n < cp.length; n++) cp[n] = true; try { tempd.setConnectPoints(cp); vmc.addPlot(tempd); if (data.attribute(ThresholdCurve.RECALL_NAME) != null) vmc.setXIndex(data.attribute(ThresholdCurve.RECALL_NAME).index()); if (data.attribute(ThresholdCurve.PRECISION_NAME) != null) vmc.setYIndex(data.attribute(ThresholdCurve.PRECISION_NAME).index()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error adding plot:\n" + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); return; } MekaFrame frame = new MekaFrame(); frame.setTitle(getName()); frame.setDefaultCloseOperation(MekaFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(vmc); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:meka.gui.guichooser.ROC.java
License:Open Source License
/** * Called by the menu items action listener. *//*from w w w .j a v a 2 s. c o m*/ @Override protected void launch() { m_FileChooser = GUIHelper.newConverterFileChooser(); // choose file int retVal = m_FileChooser.showOpenDialog(null); if (retVal != JFileChooser.APPROVE_OPTION) return; File file = m_FileChooser.getSelectedFile(); // create plot Instances data; try { data = m_FileChooser.getLoader().getDataSet(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error loading file '" + file + "':\n" + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); return; } data.setClassIndex(data.numAttributes() - 1); ThresholdVisualizePanel vmc = new ThresholdVisualizePanel(); vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(data), 4) + ")"); vmc.setName(data.relationName()); PlotData2D tempd = new PlotData2D(data); tempd.setPlotName(data.relationName()); tempd.m_displayAllPoints = true; // specify which points are connected boolean[] cp = new boolean[data.numInstances()]; for (int n = 1; n < cp.length; n++) cp[n] = true; try { tempd.setConnectPoints(cp); vmc.addPlot(tempd); if (data.attribute(ThresholdCurve.FP_RATE_NAME) != null) vmc.setXIndex(data.attribute(ThresholdCurve.FP_RATE_NAME).index()); if (data.attribute(ThresholdCurve.TP_RATE_NAME) != null) vmc.setYIndex(data.attribute(ThresholdCurve.TP_RATE_NAME).index()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error adding plot:\n" + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); return; } MekaFrame frame = new MekaFrame(); frame.setTitle(getName()); frame.setDefaultCloseOperation(MekaFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(vmc); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:milk.visualize.MIPlot2D.java
License:Open Source License
/** * Sets the plot vectors from a set of exemplars * @param added the exemplars/*from w w w . jav a 2s .co m*/ * @exception exception Exception if plots could not be set */ public void setPlotExemplars(Exemplars added) throws Exception { super.removeAllPlots(); // Set xIndex, yIndex and cIndex to 0 if (added == null) { plotExemplars = null; setEnabled(false); return; } plotExemplars = new Exemplars(added); int cIndex = plotExemplars.classIndex(); for (int i = 0; i < plotExemplars.numExemplars(); i++) { Exemplar ex = plotExemplars.exemplar(i); Instances insts = ex.getInstances(); PlotData2D tmp = new PlotData2D(insts); int num = insts.numInstances(); int[] shapes = new int[num]; int[] sizes = new int[num]; for (int j = 0; j < num; j++) { shapes[j] = Plot2D.X_SHAPE; sizes[j] = Plot2D.DEFAULT_SHAPE_SIZE; } tmp.setShapeType(shapes); tmp.setShapeSize(sizes); tmp.m_useCustomColour = false; tmp.setCindex(cIndex); tmp.setPlotName(Integer.toString((int) ex.idValue())); addPlot(tmp); // determineBound() involved } // Reset if (x != null) setXValue(x); if (y != null) setYValue(y); m_cIndex = cIndex; if (!Double.isNaN(maxC)) m_maxC = maxC; if (!Double.isNaN(minC)) m_minC = minC; }