List of usage examples for weka.gui.visualize PlotData2D PlotData2D
public PlotData2D(Instances insts)
From source file:miRdup.WekaModule.java
License:Open Source License
public static void rocCurve(Evaluation eval) { try {//w ww . ja v a2s . c o m // generate curve ThresholdCurve tc = new ThresholdCurve(); int classIndex = 0; Instances result = tc.getCurve(eval.predictions(), classIndex); result.toString(); // plot curve ThresholdVisualizePanel vmc = new ThresholdVisualizePanel(); vmc.setROCString("(Area under ROC = " + Utils.doubleToString(tc.getROCArea(result), 4) + ")"); vmc.setName(result.relationName()); PlotData2D tempd = new PlotData2D(result); tempd.setPlotName(result.relationName()); tempd.addInstanceNumberAttribute(); // specify which points are connected boolean[] cp = new boolean[result.numInstances()]; for (int n = 1; n < cp.length; n++) { cp[n] = true; } tempd.setConnectPoints(cp); // add plot vmc.addPlot(tempd); // result.toString(); // display curve String plotName = vmc.getName(); final javax.swing.JFrame jf = new javax.swing.JFrame("Weka Classifier Visualize: " + plotName); jf.setSize(500, 400); jf.getContentPane().setLayout(new BorderLayout()); jf.getContentPane().add(vmc, BorderLayout.CENTER); jf.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { jf.dispose(); } }); jf.setVisible(true); System.out.println(""); } catch (Exception e) { e.printStackTrace(); } }
From source file:trainableSegmentation.Weka_Segmentation.java
License:GNU General Public License
/** * Display the threshold curve window (for precision/recall, ROC, etc.). * * @param data input instances/*from w w w .j a v a 2 s. c om*/ * @param classifier classifier to evaluate */ public static void displayGraphs(Instances data, AbstractClassifier classifier) { ThresholdCurve tc = new ThresholdCurve(); FastVector predictions = null; try { final EvaluationUtils eu = new EvaluationUtils(); predictions = eu.getTestPredictions(classifier, data); } catch (Exception e) { IJ.log("Error while evaluating data!"); e.printStackTrace(); return; } Instances result = tc.getCurve(predictions); ThresholdVisualizePanel vmc = new ThresholdVisualizePanel(); vmc.setName(result.relationName() + " (display only)"); PlotData2D tempd = new PlotData2D(result); tempd.setPlotName(result.relationName()); tempd.addInstanceNumberAttribute(); try { vmc.addPlot(tempd); } catch (Exception e) { IJ.log("Error while adding plot to visualization panel!"); e.printStackTrace(); return; } String plotName = vmc.getName(); JFrame jf = new JFrame("Weka Classifier Visualize: " + plotName); jf.setSize(500, 400); jf.getContentPane().setLayout(new BorderLayout()); jf.getContentPane().add(vmc, BorderLayout.CENTER); jf.setVisible(true); }