Example usage for weka.classifiers.functions MultilayerPerceptron setAutoBuild

List of usage examples for weka.classifiers.functions MultilayerPerceptron setAutoBuild

Introduction

In this page you can find the example usage for weka.classifiers.functions MultilayerPerceptron setAutoBuild.

Prototype

public void setAutoBuild(boolean a) 

Source Link

Document

This will set whether the network is automatically built or if it is left up to the user.

Usage

From source file:cyber009.main.UDALNeuralNetwork.java

public static void main(String[] args) {
    UDALNeuralNetwork udal = new UDALNeuralNetwork(0.014013);
    Statistics statis = new Statistics(udal.v);
    long timeStart = 0, timeEnd = 0;
    for (int f = 2; f <= 2; f++) {
        udal.initUDAL(4, 5000);// www  . ja  v  a  2s.c o  m
        udal.activeLearning(0, 5000);
        udal.arraytoInstances();
        udal.ann.weightReset();
        timeStart = System.currentTimeMillis();
        MultilayerPerceptron wekaNN = new MultilayerPerceptron();
        wekaNN.setAutoBuild(true);
        //wekaNN.setGUI(true);
        try {
            wekaNN.buildClassifier(udal.dataSet);
            Evaluation eval = new Evaluation(udal.dataSet);
            System.out.println(wekaNN.toString());
            eval.crossValidateModel(wekaNN, udal.dataSet, 4999, new Random(System.currentTimeMillis()));
            System.out.println(wekaNN.toString());
            System.out.println(eval.toClassDetailsString());

            //            udal.ann.gradientDescent(10000L, 3, 100);
            //            for (Double target : udal.v.CLASSES) {
            //                statis.calMVMuSigma(target);
            //                System.out.println(udal.v.N_DATA_IN_CLASS.get(target));
            //                System.out.println(statis.mu.get(target));
            //                System.out.println(statis.sigma.get(target));
            //            }
            //            for(int d=0; d<udal.v.D; d++) {
            //                if(udal.v.LABEL[d] == false) {
            //                    double [][] val = new double[udal.v.N-1][1];
            //                    for(int n=1; n<udal.v.N; n++) {
            //                        val[n-1][0] = udal.v.X[d][n];
            ////                        System.out.print(udal.v.X[d][n] + "   ");
            ////                        System.out.println(val[n-1][0]);
            //                    }
            //                    Matrix mVal = new Matrix(val);
            //                    double pp = 0.0D;
            //                    for (Double target : udal.v.CLASSES) {
            //                        //System.out.println("-----------------------\nClass:"+ target);
            //                        pp += statis.posteriorDistribution(target, mVal);
            //                        System.out.println("conditional: Entropy: "+ 
            //                                statis.conditionalEntropy(target, mVal, d));
            //                    }
            //                    System.out.print("Sum posterior:"+ pp+ " for "+new Matrix(val).transpose());
            //                    
            //                }
            //            }
            //            System.out.println("-----------------------");
            //            timeEnd = System.currentTimeMillis();
            //            System.out.println("feature #:"+udal.v.N+" time:("+ (timeEnd - timeStart) +")");
            //            udal.v.showResult();
            //            
        } catch (Exception ex) {
            Logger.getLogger(UDALNeuralNetwork.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}