package weka;

import weka.classifiers.Evaluation;
import weka.classifiers.functions.MultilayerPerceptron;
import weka.core.Instances;
import weka.core.Utils;
import weka.core.converters.CSVLoader;

import java.util.Random;
import java.io.*;

/**
 * Created by garciparedes on 16/10/2016.
 */
public class WekaMultiLayerPerceptron {

    public static void main(String[] args) {
        try {

            String filepath = "./dataset/ojo-seco.csv";
            double percent = 66;

            CSVLoader loader = new CSVLoader();
            loader.setSource(new File(filepath));

            Instances data = loader.getDataSet();
            data.setClassIndex(data.numAttributes() - 1);
            data.randomize(new Random(0));


            int trainSize = (int) Math.round(data.numInstances() * percent / 100);
            int testSize = data.numInstances() - trainSize;

            Instances train = new Instances(data, 0, trainSize);
            Instances test = new Instances(data, trainSize, testSize);


            System.out.println(data.toSummaryString());


            MultilayerPerceptron mlp = new MultilayerPerceptron();

            //Setting Parameters
            mlp.setOptions(Utils.splitOptions("-L 0.3 -M 0.2 -N 500 -V 0 -S 0 -E 20 -H a"));

            mlp.buildClassifier(train);

            System.out.println(mlp.toString());



            Evaluation eval = new Evaluation(test);
            eval.evaluateModel(mlp, test);

            System.out.println(eval.toSummaryString()); //Summary of Training


        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

@@ -336,21 +336,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -350,138 +350,177 @@
 tic 
-void main(String%5B%5D args) %7B%0A        try %7B%0A%0A            String filepath = %22./dataset/ojo-seco.csv%22;%0A            double percent = 66;
+final String OJOSECO_FILEPATH = %22./dataset/ojo-seco.csv%22;%0A    private static final double RATIO_TEST = 0.66;%0A%0A    public static void main(String%5B%5D args) %7B%0A        try %7B%0A
 %0A%0A  
@@ -607,21 +607,31 @@
 ile(
-filepath
+OJOSECO_FILEPATH
 ));%0A%0A
+%0A%0A
     
@@ -733,16 +733,76 @@
 () - 1);
+%0A%0A            System.out.println(data.toSummaryString());%0A%0A%0A
 %0A       
@@ -834,25 +834,24 @@
 andom(0));%0A%0A
-%0A
             
@@ -870,14 +870,24 @@
 e = 
-(int) 
+Math.toIntExact(
 Math
@@ -919,21 +919,19 @@
 ) * 
-percent / 100
+RATIO_TEST)
 );%0A 
@@ -1132,65 +1132,8 @@
 ;%0A%0A%0A
-            System.out.println(data.toSummaryString());%0A%0A
 %0A   
@@ -1199,42 +1199,8 @@
 n();
-%0A%0A            //Setting Parameters
 %0A   
@@ -1285,25 +1285,24 @@
 20 -H a%22));%0A
-%0A
             
@@ -1536,30 +1536,8 @@
 ());
- //Summary of Training
 %0A%0A%0A 

Reformat Code