Example usage for weka.gui.visualize VisualizePanel addPlot

List of usage examples for weka.gui.visualize VisualizePanel addPlot

Introduction

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

Prototype

public void addPlot(PlotData2D newPlot) throws Exception 

Source Link

Document

Set a new plot to the visualize panel

Usage

From source file:adams.gui.menu.MarginCurve.java

License:Open Source License

/**
 * Launches the functionality of the menu item.
 *//*from w w  w  .  j ava  2 s  .com*/
@Override
public void launch() {
    File file;
    if (m_Parameters.length == 0) {
        // choose file
        int retVal = m_FileChooser.showOpenDialog(null);
        if (retVal != JFileChooser.APPROVE_OPTION)
            return;
        file = m_FileChooser.getSelectedFile();
    } else {
        file = new PlaceholderFile(m_Parameters[0]).getAbsoluteFile();
        m_FileChooser.setSelectedFile(file);
    }

    // create plot
    Instances result;
    try {
        result = m_FileChooser.getLoader().getDataSet();
    } catch (Exception e) {
        GUIHelper.showErrorMessage(getOwner(),
                "Error loading file '" + file + "':\n" + adams.core.Utils.throwableToString(e));
        return;
    }
    result.setClassIndex(result.numAttributes() - 1);
    VisualizePanel vp = new VisualizePanel();
    PlotData2D plot = new PlotData2D(result);
    plot.m_displayAllPoints = true;
    boolean[] connectPoints = new boolean[result.numInstances()];
    for (int cp = 1; cp < connectPoints.length; cp++)
        connectPoints[cp] = true;
    try {
        plot.setConnectPoints(connectPoints);
        vp.addPlot(plot);
    } catch (Exception e) {
        GUIHelper.showErrorMessage(getOwner(), "Error adding plot:\n" + adams.core.Utils.throwableToString(e));
        return;
    }

    ChildFrame frame = createChildFrame(vp, GUIHelper.getDefaultDialogDimension());
    frame.setTitle(frame.getTitle() + " - " + file);
}

From source file:cyber009.main.MainSyntacticData.java

public static void main(String[] args) {
    Random r = new Random(System.currentTimeMillis());
    Variable v = new Variable();
    long timeStart = 0, timeEnd = 0;
    ANN ann = new ANN(v, 0.014013);
    for (int f = 2; f <= 2; f++) {
        v.N = f;/*from  w w w  .j  a  va2 s .co m*/
        v.D = 4000;
        v.threshold = 0.0;
        cyber009.function.LinearFunction func = new cyber009.function.LinearFunction(v.N);
        v.X = new double[v.D][];
        v.TARGET = new double[v.D];
        v.WEIGHT = new double[v.N + 1];
        for (int d = 0; d < v.D; d++) {
            v.X[d] = new double[v.N + 1];
            v.X[d][0] = 1.0;
            for (int n = 1; n <= v.N; n++) {
                v.X[d][n] = r.nextGaussian();
            }
            v.TARGET[d] = func.syntacticFunction(v.X[d], v.threshold);
        }

        //v.showAll();
        //Lib.Utility.writeCSVDataSet("data/syn_data_x_"+v.N+"_d_"+v.D+".csv", v);

        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]);
        }
        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);
        }

        ann.weightReset();
        timeStart = System.currentTimeMillis();
        ann.gradientDescent(10000L, 2, v.D);
        timeEnd = System.currentTimeMillis();
        //v.showTable();
        //v.showWEIGHT();
        System.out.println("feature #:" + v.N + " time:(" + (timeEnd - timeStart) + ")");
        v.showResult();
        //func.showCoefficients();
    }
}

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  w w .j  a v a 2s.  com
    }
    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   w w w . ja va  2  s .  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());/*  ww  w  .  j  a v a2  s  .com*/
    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.IncrementalPerformance.java

License:Open Source License

/**
 * Creates a panel displaying the data./*  www.ja va 2  s.c om*/
 *
 * @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  a 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("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./*from   w  ww  .j a va 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("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;
}