List of usage examples for weka.gui.experiment ExperimenterDefaults getComparisonField
public final static String getComparisonField()
From source file:adams.flow.transformer.WekaExperimentEvaluation.java
License:Open Source License
/** * Sets up the testing algorithm and returns it. * * @param data the experimental data//from ww w .java 2 s . c o m * @return the configured testing algorithm * @throws Exception If something goes wrong, like testing algorithm of * result matrix cannot be instantiated */ protected Tester getTester(Instances data) throws Exception { Tester ttester; ResultMatrix matrix; String tmpStr; weka.core.Attribute att; List<String> rows; List<String> cols; String selectedList; String selectedListDataset; boolean comparisonFieldSet; int i; String name; Range generatorRange; ttester = (Tester) Utils.deepCopy(m_Tester); matrix = (ResultMatrix) Utils.deepCopy(m_OutputFormat); ttester.setInstances(data); ttester.setSignificanceLevel(m_Significance); ttester.setShowStdDevs(matrix.getShowStdDev()); ttester.setSortColumn(-1); if (!m_SwapRowsAndColumns) { rows = determineColumnNames(m_Row, ExperimenterDefaults.getRow()); cols = determineColumnNames(m_Column, ExperimenterDefaults.getColumn()); } else { cols = determineColumnNames(m_Row, ExperimenterDefaults.getRow()); rows = determineColumnNames(m_Column, ExperimenterDefaults.getColumn()); } selectedList = ""; selectedListDataset = ""; comparisonFieldSet = false; for (i = 0; i < data.numAttributes(); i++) { name = data.attribute(i).name(); if (rows.contains(name.toLowerCase())) { selectedListDataset += "," + (i + 1); } else if (name.toLowerCase().equals("key_run")) { ttester.setRunColumn(i); } else if (name.toLowerCase().equals("key_fold")) { ttester.setFoldColumn(i); } else if (cols.contains(name.toLowerCase())) { selectedList += "," + (i + 1); } else if (name.toLowerCase().contains(ExperimenterDefaults.getComparisonField())) { comparisonFieldSet = true; } else if ((name.toLowerCase().contains("root_relative_squared_error")) && (!comparisonFieldSet)) { comparisonFieldSet = true; } } generatorRange = new Range(); if (selectedList.length() != 0) { try { generatorRange.setRanges(selectedList); } catch (Exception ex) { handleException("Failed to set ranges: " + selectedList, ex); } } ttester.setResultsetKeyColumns(generatorRange); generatorRange = new Range(); if (selectedListDataset.length() != 0) { try { generatorRange.setRanges(selectedListDataset); } catch (Exception ex) { handleException("Failed to set dataset ranges: " + selectedListDataset, ex); } } ttester.setDatasetKeyColumns(generatorRange); tmpStr = m_ComparisonField.getField(); att = data.attribute(tmpStr); if (att == null) throw new Exception("Cannot find comparison field '" + tmpStr + "' in data!"); ttester.setDisplayedResultsets(null); // all ttester.setResultMatrix(matrix); return ttester; }