diff --git a/src/main/java/es/upm/dit/gsi/barmas/dataset/utils/WekaDatasetSplitter.java b/src/main/java/es/upm/dit/gsi/barmas/dataset/utils/WekaDatasetSplitter.java new file mode 100644 index 0000000..bf241b3 --- /dev/null +++ b/src/main/java/es/upm/dit/gsi/barmas/dataset/utils/WekaDatasetSplitter.java @@ -0,0 +1,282 @@ +/******************************************************************************* + * Copyright (c) 2013 alvarocarrera Grupo de Sistemas Inteligentes - Universidad Politécnica de Madrid. (GSI-UPM) + * http://www.gsi.dit.upm.es/ + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v2.0 + * which accompanies this distribution, and is available at + * + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + * + * Contributors: + * alvarocarrera - initial API and implementation + ******************************************************************************/ +/** + * es.upm.dit.gsi.barmas.kowlancz.dataset.utils.DatasetSplitter.java + */ +package es.upm.dit.gsi.barmas.dataset.utils; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Logger; + +import weka.core.Instance; +import weka.core.Instances; +import weka.core.converters.CSVSaver; +import weka.core.converters.ConverterUtils.DataSource; + +import com.csvreader.CsvReader; +import com.csvreader.CsvWriter; + +/** + * Project: barmas File: + * es.upm.dit.gsi.barmas.dataset.utils.kowlancz.DatasetSplitter.java + * + * Grupo de Sistemas Inteligentes Departamento de Ingeniería de Sistemas + * Telemáticos Universidad Politécnica de Madrid (UPM) + * + * @author alvarocarrera + * @email a.carrera@gsi.dit.upm.es + * @twitter @alvarocarrera + * @date 31/10/2013 + * @version 0.2 + * + */ +public class WekaDatasetSplitter { + + /** + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + + WekaDatasetSplitter splitter = new WekaDatasetSplitter(); + + String originalDatasetPath = "src/main/resources/dataset/kowlancz/CZ02/CZ02-dataset.csv"; + String outputParentDir = "src/main/resources/output/kowlancz-CZ02"; + Logger logger = Logger.getLogger(WekaDatasetSplitter.class.getSimpleName()); + + // Experiment 1 + String outputDir = outputParentDir; + splitter.splitDataset(3, 4, originalDatasetPath, outputDir, "CZ02", logger); + + // Experiment 2 + outputDir = outputParentDir; + splitter.splitDataset(10, 8, originalDatasetPath, outputDir, "CZ02", logger); + + } + + /** + * This method splits the original dataset in many small datasets for a + * given number of agents. + * + * This method uses folds generated by WEKA and appends the language at the + * end of the datasets (i.e. the essentials). + * + * @param folds + * KFold number + * @param agents + * number of agents to split the original dataset + * @param originalDatasetPath + * @param outputDir + * @param central + * true to create a bayescentral dataset that joint all agent + * data + * @param scenario + * @param iteration + * @throws Exception + */ + public void splitDataset(int folds, int agents, String originalDatasetPath, String outputDir, + String scenario, Logger logger) { + + int ratioint = (int) ((1 / (double) folds) * 100); + double roundedratio = ((double) ratioint) / 100; + + // Look for essentials + List essentials = this.getEssentials(originalDatasetPath, logger); + + for (int fold = 0; fold < folds; fold++) { + String outputDirWithRatio = outputDir + "/" + roundedratio + "testRatio/iteration-" + + fold; + File dir = new File(outputDirWithRatio); + if (!dir.exists() || !dir.isDirectory()) { + dir.mkdirs(); + } + + logger.finer("--> splitDataset()"); + logger.fine("Creating experiment.info..."); + this.createExperimentInfoFile(folds, agents, originalDatasetPath, outputDirWithRatio, + scenario, logger); + + try { + + Instances originalData = this.getDataFromCSV(originalDatasetPath); + + // TestDataSet + Instances testData = originalData.testCV(folds, fold); + CSVSaver saver = new CSVSaver(); + saver.setInstances(testData); + saver.setFile(new File(outputDirWithRatio + File.separator + "test-dataset.csv")); + saver.writeBatch(); + + // BayesCentralDataset + Instances trainData = originalData.trainCV(folds, fold); + saver.resetOptions(); + saver.setInstances(trainData); + saver.setFile(new File(outputDirWithRatio + File.separator + + "bayes-central-dataset.csv")); + saver.writeBatch(); + + // Agent datasets + CsvReader csvreader = new CsvReader(new FileReader(new File(originalDatasetPath))); + csvreader.readHeaders(); + String[] headers = csvreader.getHeaders(); + csvreader.close(); + + HashMap writers = new HashMap(); + String agentsDatasetsDir = outputDirWithRatio + File.separator + agents + "agents"; + File f = new File(agentsDatasetsDir); + if (!f.isDirectory()) { + f.mkdirs(); + } + for (int i = 0; i < agents; i++) { + String fileName = agentsDatasetsDir + File.separator + "agent-" + i + + "-dataset.csv"; + CsvWriter writer = new CsvWriter(new FileWriter(fileName), ','); + writer.writeRecord(headers); + writers.put("AGENT" + i, writer); + logger.fine("AGENT" + i + " dataset created."); + } + + int agentCounter = 0; + for (int i = 0; i < trainData.numInstances(); i++) { + Instance instance = trainData.instance(i); + CsvWriter writer = writers.get("AGENT" + agentCounter); + String[] row = new String[instance.numAttributes()]; + for (int a = 0; a < instance.numAttributes(); a++) { + row[a] = instance.stringValue(a); + } + writer.writeRecord(row); + agentCounter++; + if (agentCounter == agents) { + agentCounter = 0; + } + } + + // Append essentials to all + String fileName = outputDirWithRatio + File.separator + "bayes-central-dataset.csv"; + CsvWriter w = new CsvWriter(new FileWriter(fileName, true), ','); + writers.put("CENTRAL", w); + for (String[] essential : essentials) { + for (CsvWriter writer : writers.values()) { + writer.writeRecord(essential); + } + } + for (CsvWriter writer : writers.values()) { + writer.close(); + } + + } catch (Exception e) { + logger.severe("Exception while splitting dataset. ->"); + logger.severe(e.getMessage()); + System.exit(1); + } + + logger.finest("Dataset for fold " + fold + " created."); + } + + logger.finer("<-- splitDataset()"); + } + + /** + * @param ratio + * @param agents + * @param originalDatasetPath + * @param outputDir + * @param central + * @param scenario + */ + private void createExperimentInfoFile(int folds, int agents, String originalDatasetPath, + String outputDir, String scenario, Logger logger) { + + try { + String fileName = outputDir + "/" + agents + "agents/experiment.info"; + File file = new File(fileName); + File parent = file.getParentFile(); + if (!parent.exists()) { + parent.mkdirs(); + } + FileWriter fw = new FileWriter(file); + fw.write("Scenario: " + scenario + "\n"); + fw.write("Number of folds: " + Integer.toString(folds) + "\n"); + fw.write("Number of Agents: " + Integer.toString(agents) + "\n"); + fw.write("Original dataset: " + originalDatasetPath + "\n"); + fw.write("Experiment dataset folder: " + outputDir + "\n"); + fw.close(); + + } catch (Exception e) { + logger.severe(e.getMessage()); + System.exit(1); + } + } + + /** + * @param originalDatasetPath + * @param scenario + * @return + */ + private List getEssentials(String originalDatasetPath, Logger logger) { + // Find essentials + List essentials = new ArrayList(); + HashMap> nodesAndStates = new HashMap>(); + try { + // Look for all possible states + Reader fr = new FileReader(originalDatasetPath); + CsvReader reader = new CsvReader(fr); + reader.readHeaders(); + String[] headers = reader.getHeaders(); + for (String header : headers) { + nodesAndStates.put(header, new ArrayList()); + } + String[] values; + while (reader.readRecord()) { + values = reader.getValues(); + for (int i = 0; i < values.length; i++) { + if (!nodesAndStates.get(headers[i]).contains(values[i])) { + nodesAndStates.get(headers[i]).add(values[i]); + if (!essentials.contains(values)) { + essentials.add(values); + } + } + } + } + + reader.close(); + + logger.fine("Number of Essentials: " + essentials.size()); + } catch (Exception e) { + logger.severe(e.getMessage()); + System.exit(1); + } + return essentials; + } + + /** + * @param csvFilePath + * @return + * @throws Exception + */ + private Instances getDataFromCSV(String csvFilePath) throws Exception { + DataSource source = new DataSource(csvFilePath); + Instances data = source.getDataSet(); + data.setClassIndex(data.numAttributes() - 1); + return data; + } +} diff --git a/src/main/java/es/upm/dit/gsi/barmas/launcher/utils/analysis/BubbleChartGenerator.java b/src/main/java/es/upm/dit/gsi/barmas/launcher/utils/analysis/BubbleChartGenerator.java new file mode 100644 index 0000000..04f20be --- /dev/null +++ b/src/main/java/es/upm/dit/gsi/barmas/launcher/utils/analysis/BubbleChartGenerator.java @@ -0,0 +1,142 @@ +/** + * es.upm.dit.gsi.barmas.launcher.utils.analysis.BubbleChartGenerator.java + */ +package es.upm.dit.gsi.barmas.launcher.utils.analysis; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.jzy3d.colors.Color; +import org.jzy3d.colors.ColorMapper; +import org.jzy3d.colors.colormaps.ColorMapRainbow; +import org.jzy3d.maths.Coord3d; +import org.jzy3d.plot3d.primitives.Cylinder; +import org.jzy3d.plot3d.rendering.view.modes.ViewPositionMode; + +import com.csvreader.CsvReader; + +import es.upm.dit.gsi.barmas.launcher.logging.LogConfigurator; +import es.upm.dit.gsi.barmas.launcher.utils.ExperimentsAnalyser; +import es.upm.dit.gsi.barmas.launcher.utils.plot.Plotter; + +/** + * Project: barmas File: + * es.upm.dit.gsi.barmas.launcher.utils.analysis.BubbleChartGenerator.java + * + * Grupo de Sistemas Inteligentes Departamento de Ingeniería de Sistemas + * Telemáticos Universidad Politécnica de Madrid (UPM) + * + * @author alvarocarrera + * @email a.carrera@gsi.dit.upm.es + * @twitter @alvarocarrera + * @date 12/02/2014 + * @version 0.1 + * + */ +public class BubbleChartGenerator { + + private Logger logger; + private String summaryFile; + private String outputFolder; + private String outputFileName; + + /** + * Constructor + * + */ + public BubbleChartGenerator(Logger logger, String summaryFile, String outputFolder, + String outputFileName) { + this.logger = logger; + LogConfigurator.log2File(logger, ExperimentsAnalyser.class.getSimpleName(), Level.ALL, + Level.INFO, outputFolder); + this.summaryFile = summaryFile; + this.outputFolder = outputFolder; + this.outputFileName = outputFileName; + } + + public void generateBubbleChart() { + + CsvReader reader; + try { + reader = new CsvReader(new FileReader(new File(this.summaryFile))); + reader.readHeaders(); + // String[] headers = reader.getHeaders(); + + Plotter plotter = new Plotter(this.logger); + List cylinders = new ArrayList(); + + while (reader.readRecord()) { + + String[] row = reader.getValues(); + + // Parse data + String lebaS = row[4]; + int leba = Integer.parseInt(lebaS); + String agentsS = row[5]; + int agents = Integer.parseInt(agentsS); + String impS = row[6]; + float imp = Float.parseFloat(impS); + + // Build cylinder + float radius = (float) imp * 2; + float floor = 0f; + Coord3d baseCentre = new Coord3d(leba, agents, floor); + float height = 1f; + Cylinder cylinder = plotter.getCylinder(baseCentre, height, radius); + cylinder.setColorMapper(new ColorMapper(new ColorMapRainbow(), new Color(height, + height, height))); + cylinders.add(cylinder); + } + reader.close(); + + // Add new cylinder to avoid deformation (optional) + float radius = (float) 0; + float floor = 0f; + Coord3d baseCentre = new Coord3d(10, 10, floor); + float height = 1f; + Cylinder cylinder = plotter.getCylinder(baseCentre, height, radius); + cylinder.setColorMapper(new ColorMapper(new ColorMapRainbow(), new Color(height, + height, height))); + cylinders.add(cylinder); + + logger.info("Generating chart"); + String[] axisLabels = new String[3]; + axisLabels[0] = "LEBA"; + axisLabels[1] = "AGENTS"; + axisLabels[2] = ""; + // plotter.openCylinderChart(cylinders); + plotter.saveCylinder3DChart(this.outputFolder + "/" + this.outputFileName, axisLabels, + cylinders, ViewPositionMode.TOP, new Coord3d(0, 1, 0)); + + logger.info("Bubble chart generated"); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * @param args + */ + public static void main(String[] args) { + + String dataset = "nursery"; + String file = "../experiments/results/results-" + dataset + ".csv"; + String outputFolder = "../experiments/results/output"; + String outputFileName = "bubbleChart-" + dataset + ".png"; + Logger logger = Logger.getLogger(ExperimentsAnalyser.class.getSimpleName()); + BubbleChartGenerator gen = new BubbleChartGenerator(logger, file, outputFolder, + outputFileName); + gen.generateBubbleChart(); + + } + +} diff --git a/src/main/java/weka/classifiers/ClassifiersValidation.java b/src/main/java/weka/classifiers/ClassifiersValidation.java deleted file mode 100644 index dc10fe8..0000000 --- a/src/main/java/weka/classifiers/ClassifiersValidation.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * weka.classifiers.ClassifierJ48.java - */ -package weka.classifiers; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import smile.learning.NaiveBayes; - -import weka.classifiers.functions.RBFNetwork; -import weka.classifiers.rules.DTNB; -import weka.classifiers.rules.JRip; -import weka.classifiers.trees.BFTree; -import weka.classifiers.trees.J48graft; -import weka.classifiers.trees.LMT; -import weka.classifiers.trees.RandomForest; -import weka.classifiers.trees.SimpleCart; -import weka.core.Instances; -import weka.core.converters.ConverterUtils.DataSource; - -/** - * Project: barmas File: weka.classifiers.ClassifierJ48.java - * - * Grupo de Sistemas Inteligentes Departamento de Ingeniería de Sistemas - * Telemáticos Universidad Politécnica de Madrid (UPM) - * - * @author alvarocarrera - * @email a.carrera@gsi.dit.upm.es - * @twitter @alvarocarrera - * @date 14/02/2014 - * @version 0.1 - * - */ -public class ClassifiersValidation { - - /** - * Constructor - * - */ - public ClassifiersValidation() { - // TODO Auto-generated constructor stub - } - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - - try { - DataSource source = new DataSource( - "../experiments/solarflare-simulation/input/0.1testRatio/iteration-2/bayes-central-dataset.csv"); - Instances data = source.getDataSet(); - data.setClassIndex(data.numAttributes() - 1); - - source = new DataSource( - "../experiments/solarflare-simulation/input/0.1testRatio/iteration-2/test-dataset.csv"); - Instances test = source.getDataSet(); - test.setClassIndex(test.numAttributes() - 1); - - Classifier cls; - - // LADTree - // cls = new LADTree(); - - // REPTree - // cls = new REPTree(); - - // NBTree - // cls = new NBTree(); - - // SimpleLogistic - // cls = new SimpleLogistic(); - - // Logistic - // cls = new Logistic(); - - // MultiLayerPerceptron - // cls = new MultilayerPerceptron(); - - // DecisionStump - // cls = new DecisionStump(); - - // PART - // cls = new PART(); - - // RandomForest - // cls = new RandomForest(); - - // LMT - // cls = new LMT(); - - // SimpleCart - // cls = new SimpleCart(); - - // BFTree - // cls = new BFTree(); - - // RBFNetwork - cls = new RBFNetwork(); - - // J48 - // cls = new J48(); - // ((J48) cls).setUnpruned(true); - - // J48Graft - // cls = new J48graft(); - // ((J48graft) cls).setUnpruned(true); - - // DTNB - // cls = new DTNB(); - - // Jrip - // cls = new JRip(); - - // Conjunction Rule - // cls = new ConjunctiveRule(); - - // ZeroR - // cls = new ZeroR(); - - // OneR - // cls = new OneR(); - - // SMO - // cls = new SMO(); - - cls.buildClassifier(data); - - Evaluation eval = new Evaluation(data); - eval.evaluateModel(cls, test); - System.out.println("Correct %: " + eval.pctCorrect()); - System.out.println("Incorrect %: " + eval.pctIncorrect()); - System.out.println("TOTAL %: " + (eval.pctIncorrect() + eval.pctCorrect())); - - // System.out.println(eval.toSummaryString("\nResults\n======\n", - // false)); - - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/src/test/java/weka/classifiers/ClassifiersValidation.java b/src/test/java/weka/classifiers/ClassifiersValidation.java new file mode 100644 index 0000000..4f628f9 --- /dev/null +++ b/src/test/java/weka/classifiers/ClassifiersValidation.java @@ -0,0 +1,283 @@ +/** + * weka.classifiers.ClassifierJ48.java + */ +package weka.classifiers; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import weka.classifiers.functions.Logistic; +import weka.classifiers.functions.MultilayerPerceptron; +import weka.classifiers.functions.RBFNetwork; +import weka.classifiers.functions.SMO; +import weka.classifiers.functions.SimpleLogistic; +import weka.classifiers.rules.ConjunctiveRule; +import weka.classifiers.rules.DTNB; +import weka.classifiers.rules.JRip; +import weka.classifiers.rules.OneR; +import weka.classifiers.rules.PART; +import weka.classifiers.rules.ZeroR; +import weka.classifiers.trees.BFTree; +import weka.classifiers.trees.DecisionStump; +import weka.classifiers.trees.J48; +import weka.classifiers.trees.J48graft; +import weka.classifiers.trees.LADTree; +import weka.classifiers.trees.LMT; +import weka.classifiers.trees.NBTree; +import weka.classifiers.trees.REPTree; +import weka.classifiers.trees.RandomForest; +import weka.classifiers.trees.SimpleCart; +import weka.core.Instances; +import weka.core.converters.ConverterUtils.DataSource; + +/** + * Project: barmas File: weka.classifiers.ClassifierJ48.java + * + * Grupo de Sistemas Inteligentes Departamento de Ingeniería de Sistemas + * Telemáticos Universidad Politécnica de Madrid (UPM) + * + * @author alvarocarrera + * @email a.carrera@gsi.dit.upm.es + * @twitter @alvarocarrera + * @date 14/02/2014 + * @version 0.1 + * + */ +public class ClassifiersValidation { + + private static Logger logger = Logger.getLogger(ClassifiersValidation.class.getSimpleName()); + + /** + * Constructor + * + */ + public ClassifiersValidation() { + } + + /** + * @param csvFilePath + * @return + * @throws Exception + */ + public Instances getDataFromCSV(String csvFilePath) throws Exception { + DataSource source = new DataSource(csvFilePath); + Instances data = source.getDataSet(); + data.setClassIndex(data.numAttributes() - 1); + return data; + } + + /** + * @param cls + * @param trainingData + * @param testData + * @return [0] = pctCorrect, [1] = pctIncorrect + * @throws Exception + */ + public double[] getValidation(Classifier cls, Instances trainingData, Instances testData) + throws Exception { + + cls.buildClassifier(trainingData); + + Evaluation eval = new Evaluation(trainingData); + eval.evaluateModel(cls, testData); + + double[] results = new double[2]; + results[0] = eval.pctCorrect() / 100; + results[1] = eval.pctIncorrect() / 100; + return results; + } + + /** + * @param cls + * @param data + * @param folds + * @return [0] = pctCorrect, [1] = pctIncorrect + * @throws Exception + */ + public double[] getCrossValidation(Classifier cls, Instances data, int folds) throws Exception { + + cls.buildClassifier(data); + + Classifier copy = Classifier.makeCopy(cls); + double[] results = new double[2]; + for (int n = 0; n < folds; n++) { + Instances train = data.trainCV(folds, n); + Instances test = data.testCV(folds, n); + + // CSVSaver saver = new CSVSaver(); + // saver.setInstances(train); + // saver.setFile(new File("../data.csv")); + // saver.writeBatch(); + + cls.buildClassifier(train); + Evaluation eval = new Evaluation(data); + eval.evaluateModel(cls, test); + results[0] = results[0] + (eval.pctCorrect() / 100); + results[1] = results[1] + (eval.pctIncorrect() / 100); + } + + cls = copy; + results[0] = results[0] / folds; + results[1] = results[1] / folds; + return results; + } + + public void saveToCSV() { + // TODO save all data into csv (getting info from DB) + } + + // TODO hacer metodo que recorra todas las iteraciones y las valide con un + // número dado de agentes + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + ClassifiersValidation cv = new ClassifiersValidation(); + + int iterations = 10; + + Classifier cls; + List clss = new ArrayList(); + + // LADTree + cls = new LADTree(); + clss.add(cls); + + // REPTree + cls = new REPTree(); + clss.add(cls); + + // NBTree + cls = new NBTree(); + clss.add(cls); + + // SimpleLogistic + cls = new SimpleLogistic(); + clss.add(cls); + + // Logistic + cls = new Logistic(); + clss.add(cls); + + // MultiLayerPerceptron + cls = new MultilayerPerceptron(); + clss.add(cls); + + // DecisionStump + cls = new DecisionStump(); + clss.add(cls); + + // PART + cls = new PART(); + clss.add(cls); + + // RandomForest + cls = new RandomForest(); + clss.add(cls); + + // LMT + cls = new LMT(); + clss.add(cls); + + // SimpleCart + cls = new SimpleCart(); + clss.add(cls); + + // BFTree + cls = new BFTree(); + clss.add(cls); + + // RBFNetwork + cls = new RBFNetwork(); + clss.add(cls); + + // J48 + cls = new J48(); + ((J48) cls).setUnpruned(true); + clss.add(cls); + + // J48Graft + cls = new J48graft(); + ((J48graft) cls).setUnpruned(true); + clss.add(cls); + + // DTNB + cls = new DTNB(); + clss.add(cls); + + // Jrip + cls = new JRip(); + clss.add(cls); + + // Conjunction Rule + cls = new ConjunctiveRule(); + clss.add(cls); + + // ZeroR + cls = new ZeroR(); + clss.add(cls); + + // OneR + cls = new OneR(); + clss.add(cls); + + // SMO + cls = new SMO(); + clss.add(cls); + + for (int j = 0; j < clss.size(); j++) { + logger.info("Starting cross-validation evaluation for " + + clss.get(j).getClass().getSimpleName()); + + try { + + Instances trainingData = cv + .getDataFromCSV("src/main/resources/dataset/solarflare.csv"); + Classifier classifier = clss.get(j); + double[] results = cv.getCrossValidation(classifier, trainingData, 10); + logger.finer("-> " + classifier.getClass().getSimpleName()); + logger.info("Success Rate / Error Rate -> " + + clss.get(j).getClass().getSimpleName() + " -> " + results[0] + " / " + + results[1]); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + double[] errors = new double[clss.size()]; + double[] success = new double[clss.size()]; + + for (int j = 0; j < clss.size(); j++) { + logger.info("Starting evaluation for " + clss.get(j).getClass().getSimpleName()); + for (int i = 0; i < iterations; i++) { + String folder = "../experiments/solarflare-simulation/input/0.1testRatio/iteration-" + + i + "/"; + try { + Instances trainingData = cv + .getDataFromCSV(folder + "bayes-central-dataset.csv"); + Instances testData = cv.getDataFromCSV(folder + "test-dataset.csv"); + Classifier classifier = clss.get(j); + double[] results = cv.getValidation(classifier, trainingData, testData); + logger.finer("-> " + classifier.getClass().getSimpleName()); + double errorRates = errors[j]; + errors[j] = errorRates + results[1]; + double successRates = success[j]; + success[j] = successRates + results[0]; + logger.finer("ER for iteration " + i + ": " + results[1]); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + logger.info("Success Rate / Error Rate -> " + clss.get(j).getClass().getSimpleName() + + " -> " + success[j] / iterations + " / " + errors[j] / iterations); + } + } +}