weka.core.Utils.splitOptions()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中weka.core.Utils.splitOptions()方法的一些代码示例,展示了Utils.splitOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.splitOptions()方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:splitOptions

Utils.splitOptions介绍

[英]Split up a string containing options into an array of strings, one for each option.
[中]将包含选项的字符串拆分为字符串数组,每个选项对应一个字符串。

代码示例

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * 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);
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * 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);
}

代码示例来源:origin: net.sf.meka/meka

/**
 * 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;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * 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());
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * 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());
}

代码示例来源:origin: dnmilne/wikipediaminer

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) ;
}

代码示例来源:origin: nz.ac.waikato.cms.moa/moa

@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();
}

代码示例来源:origin: nz.ac.waikato.cms.moa/moa

@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();
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

/**
 * 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;
}

代码示例来源:origin: dnmilne/wikipediaminer

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) ;
}

代码示例来源:origin: dnmilne/wikipediaminer

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) ;
}

代码示例来源:origin: dnmilne/wikipediaminer

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) ;
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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());
 }
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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());
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/distributedWekaBase

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;
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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());
 }
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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);
 }
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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);
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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);
}

代码示例来源:origin: com.github.fracpete/multisearch-weka-package

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);
}

相关文章