Example usage for weka.gui.visualize VisualizePanel setName

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

Introduction

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

Prototype

@Override
public void setName(String plotName) 

Source Link

Document

Set a name for this plot

Usage

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  .ja v a2s  .  c o  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 av  a  2s .co m
    }
    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.j a  v a 2s  .  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());
    try {//  ww  w.ja va 2 s  .c o  m
        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);
    }
}