/** * Split up a string containing options into an array of strings, one for each * option. * * @param quotedOptionString the string containing the options * @return the array of options * @throws Exception in case of an unterminated string, unknown character or a * parse error */ public static String[] splitOptions(String quotedOptionString) throws Exception { return splitOptions(quotedOptionString, null, null); }
/** * Split up a string containing options into an array of strings, one for each * option. * * @param quotedOptionString the string containing the options * @return the array of options * @throws Exception in case of an unterminated string, unknown character or a * parse error */ public static String[] splitOptions(String quotedOptionString) throws Exception { return splitOptions(quotedOptionString, null, null); }
/** * Gets the current settings of the classifier. * * @return an array of strings suitable for passing to setOptions */ public String [] getOptions() { //These are just examples, modify to suit your algorithm String [] options = new String [3]; try{ options =weka.core.Utils.splitOptions("-P 0.9 -K"); }catch (Exception ex) { System.out.println(ex.getMessage()); } return options; }
/** * returns the current DOM document as string array. * * @return the document as string array * @throws Exception if anything goes wrong initializing the parsing */ public String[] toArray() throws Exception { return Utils.splitOptions(toCommandLine()); }
/** * returns the current DOM document as string array. * * @return the document as string array * @throws Exception if anything goes wrong initializing the parsing */ public String[] toArray() throws Exception { return Utils.splitOptions(toCommandLine()); }
public void buildDefaultClassifier() throws Exception { Logger.getLogger(TopicIndexer.class).info("building classifier") ; Classifier classifier = new Bagging() ; classifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ; decider.train(classifier, dataset) ; }
@Override public void resetLearningImpl() { try { //System.out.println(baseLearnerOption.getValue()); String[] options = weka.core.Utils.splitOptions(baseLearnerOption.getValueAsCLIString()); createWekaClassifier(options); } catch (Exception e) { System.err.println("[ERROR] Creating a new classifier: " + e.getMessage()); } isClassificationEnabled = false; //this.isBufferStoring = true; this.instanceConverter = new SamoaToWekaInstanceConverter(); }
@Override public void resetLearningImpl() { try { //System.out.println(baseLearnerOption.getValue()); String[] options = weka.core.Utils.splitOptions(baseLearnerOption.getValueAsCLIString()); createWekaClassifier(options); } catch (Exception e) { System.err.println("Creating a new classifier: " + e.getMessage()); } numberInstances = 0; isClassificationEnabled = false; this.isBufferStoring = true; this.instanceConverter = new SamoaToWekaInstanceConverter(); }
/** * Splits the list string using the appropriate delimiter. * * @return the list items * @throws Exception if the splitting fails */ public String[] getItems() throws Exception { String[] result; if (getCustomDelimiter().isEmpty()) result = Utils.splitOptions(getList()); else result = getList().split(getCustomDelimiter()); return result; }
public void buildDefaultClassifier() throws Exception { Classifier classifier = new Bagging() ; classifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ; decider.train(classifier, dataset) ; }
public void buildDefaultClassifier() throws Exception { Classifier classifier = new Bagging() ; classifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ; decider.train(classifier, dataset) ; }
public void buildDefaultClassifiers() throws Exception { Classifier ssClassifier = new Bagging() ; ssClassifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ; senseSelector.train(ssClassifier, senseDataset) ; Classifier rmClassifier = new GaussianProcesses() ; relatednessMeasurer.train(rmClassifier, relatednessDataset) ; }
public void testMLPLayersParamIllegalLayerSizeRaises() { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayerSize 4 -maxLayerSize 2"; try { mlplayers.setOptions(Utils.splitOptions(options)); fail("expected error was not raised"); } catch (Exception e) { String expected = "minLayerSize should be smaller than or equal to maxLayerSize"; assertEquals(expected, e.getMessage()); } }
public void testMLPLayersParamIllegalBothRaises() { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayers 2 -maxLayers 2 -minLayerSize 4 -maxLayerSize 4"; try { mlplayers.setOptions(Utils.splitOptions(options)); fail("expected error was not raised"); } catch (Exception e) { String expected = "no variation in layer structure possible"; assertEquals(expected, e.getMessage()); } }
protected WekaClassifierMapTask setupIncrementalRegressor() { WekaClassifierMapTask task = new WekaClassifierMapTask(); weka.classifiers.functions.SGD sgd = new weka.classifiers.functions.SGD(); try { sgd.setOptions(Utils.splitOptions("-F 2")); task.setClassifier(sgd); } catch (Exception e) { e.printStackTrace(); } return task; }
public void testMLPLayersParamIllegalLayersRaises() { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayers 4 -maxLayers 2"; try { mlplayers.setOptions(Utils.splitOptions(options)); fail("expected error was not raised"); } catch (Exception e) { String expected = "minLayers should be smaller than or equal to maxLayers"; assertEquals(expected, e.getMessage()); } }
public void testListParameterFlag() throws Exception { ListParameter listparameter = new ListParameter(); String options = "-list \"true false\" -property \"unpruned\""; listparameter.setOptions(Utils.splitOptions(options)); Vector<Performance> results = searchValuesAll(listparameter, new J48()); Map<Boolean, Boolean> expectedValues = new HashMap<Boolean, Boolean>(); for (Performance result : results) { J48 current = (J48) result.m_Classifier; expectedValues.put(current.getUnpruned(), true); } verifyExpectedValues(expectedValues, 2); assertEquals(expectedValues.size(), 2); } }
public void testMLPLayersParamLarge() throws Exception { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayers 1 -maxLayers 32 -minLayerSize 128 -maxLayerSize 256"; mlplayers.setOptions(Utils.splitOptions(options)); assertTrue(mlplayers.getMinLayers() == 1); assertTrue(mlplayers.getMaxLayers() == 32); assertTrue(mlplayers.getMinLayerSize() == 128); assertTrue(mlplayers.getMaxLayerSize() == 256); String[] items = mlplayers.getItems(); assertTrue(items.length == MLPLayersParameter.MAX_CANDIDATES_TO_GENERATE); }
public void testMLPLayersParamSmall() throws Exception { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayers 1 -maxLayers 2 -minLayerSize 4 -maxLayerSize 8"; mlplayers.setOptions(Utils.splitOptions(options)); assertTrue(mlplayers.getMinLayers() == 1); assertTrue(mlplayers.getMaxLayers() == 2); assertTrue(mlplayers.getMinLayerSize() == 4); assertTrue(mlplayers.getMaxLayerSize() == 8); String[] items = mlplayers.getItems(); int expectedSize = 30; // 5^1 + 5^2 assertTrue(expectedSize == mlplayers.calculateNumberOfCandidates()); assertTrue(items.length == expectedSize); }
public void testMLPLayersParamMedium() throws Exception { MLPLayersParameter mlplayers = new MLPLayersParameter(); String options = "-minLayers 1 -maxLayers 4 -minLayerSize 9 -maxLayerSize 16"; mlplayers.setOptions(Utils.splitOptions(options)); assertTrue(mlplayers.getMinLayers() == 1); assertTrue(mlplayers.getMaxLayers() == 4); assertTrue(mlplayers.getMinLayerSize() == 9); assertTrue(mlplayers.getMaxLayerSize() == 16); String[] items = mlplayers.getItems(); int expectedSize = 4680; // * 8^1 + 8^2 + 8^3 + 8^4 assertTrue(expectedSize == mlplayers.calculateNumberOfCandidates()); assertTrue(items.length == expectedSize); }