Example usage for weka.gui.visualize ThresholdVisualizePanel ThresholdVisualizePanel

List of usage examples for weka.gui.visualize ThresholdVisualizePanel ThresholdVisualizePanel

Introduction

In this page you can find the example usage for weka.gui.visualize ThresholdVisualizePanel ThresholdVisualizePanel.

Prototype

public ThresholdVisualizePanel() 

Source Link

Document

default constructor

Usage

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 ww. j a  va2s  .c  o 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./*from   w ww  . j  av a2  s  .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  . j  ava2 s. 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("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.//w ww.  j a  va  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("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.
 *///from  ww w .  j  av a2  s.  com
@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.
 *//* 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:miRdup.WekaModule.java

License:Open Source License

public static void rocCurve(Evaluation eval) {
    try {// w  ww.ja v a  2s  .co 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 ww . j  a  v  a 2 s.c o m*/
 * @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);
}