本文整理汇总了Java中weka.core.Utils.splitOptions方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.splitOptions方法的具体用法?Java Utils.splitOptions怎么用?Java Utils.splitOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Utils
的用法示例。
在下文中一共展示了Utils.splitOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Parses a given list of options. Valid options are:
*
* <!-- options-start --> <!-- options-end -->
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
@Override
public void setOptions(String[] options) throws Exception {
String nnSearchClass = Utils.getOption('A', options);
if (nnSearchClass.length() != 0) {
String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
if (nnSearchClassSpec.length == 0) {
throw new Exception("Invalid DistanceFunction specification string.");
}
String className = nnSearchClassSpec[0];
nnSearchClassSpec[0] = "";
setDistanceFunction((DistanceFunction) Utils.forName(
DistanceFunction.class, className, nnSearchClassSpec));
} else {
setDistanceFunction(new EuclideanDistance());
}
setMeasurePerformance(Utils.getFlag('P', options));
}
示例2: actionPerformed
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Fired when action got executed.
*
* @param e the event
*/
public void actionPerformed(ActionEvent e) {
String retVal;
retVal = JOptionPane.showInputDialog(
FileScriptingPanel.this,
"Please enter the command-line arguments",
Utils.joinOptions(m_Args));
if (retVal == null)
return;
try {
m_Args = Utils.splitOptions(retVal);
}
catch (Exception ex) {
m_Args = new String[0];
ex.printStackTrace();
JOptionPane.showMessageDialog(
FileScriptingPanel.this,
"Error setting command-line arguments:\n" + ex,
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
示例3: trainClassifier
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Train the classifier with the given dataset
* @param trainingData The dataset to be given for classification
* @throws ClassifierException If classification fails for some reason
*/
public void trainClassifier(Instances trainingData,String pathToSaveModel,
boolean crossValidate) throws ClassifierException {
log.info("Training the classifier with "+trainingData.numInstances()+" instances");
SMO smoClassifier = new SMO();
trainingData.setClass(trainingData.attribute("@@[email protected]@"));
try {
String[] options = Utils.splitOptions("-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K \"weka.classifiers" +
".functions.supportVector.PolyKernel -C 250007 -E 1.0\"");
smoClassifier.setOptions(options);
smoClassifier.buildClassifier(trainingData);
classifier = smoClassifier;
if(crossValidate){
crossValidate(trainingData);
}
saveModel(new File(pathToSaveModel,"latest.model").getAbsolutePath());
log.info("Model built and saved");
} catch (Exception e) {
log.error("Training classifier failed.",e);
throw new ClassifierException("Classification failed.",e);
}
}
示例4: getClustererAssignmentsPlotInstances
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns an instance of the class used for generating plot instances for
* displaying the cluster assignments.
*
* @return an instance of the class
*/
public static ClustererAssignmentsPlotInstances getClustererAssignmentsPlotInstances() {
ClustererAssignmentsPlotInstances result;
String classname;
String[] options;
try {
options = Utils.splitOptions(get("ClustererAssignmentsPlotInstances",
"weka.gui.explorer.ClustererAssignmentsPlotInstances"));
classname = options[0];
options[0] = "";
result = (ClustererAssignmentsPlotInstances) Utils.forName(
ClustererAssignmentsPlotInstances.class, classname, options);
} catch (Exception e) {
e.printStackTrace();
result = new ClustererAssignmentsPlotInstances();
}
return result;
}
示例5: getClassifierErrorsPlotInstances
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns an instance of the class used for generating plot instances for
* displaying the classifier errors.
*
* @return an instance of the class
*/
public static ClassifierErrorsPlotInstances getClassifierErrorsPlotInstances() {
ClassifierErrorsPlotInstances result;
String classname;
String[] options;
try {
options = Utils.splitOptions(get("ClassifierErrorsPlotInstances",
"weka.gui.explorer.ClassifierErrorsPlotInstances"));
classname = options[0];
options[0] = "";
result = (ClassifierErrorsPlotInstances) Utils.forName(
ClassifierErrorsPlotInstances.class, classname, options);
} catch (Exception e) {
e.printStackTrace();
result = new ClassifierErrorsPlotInstances();
}
return result;
}
示例6: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Parses a given list of options.
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
@Override
public void setOptions(String[] options) throws Exception {
String tmpStr;
String[] tmpOptions;
List<StopwordsHandler> handlers;
handlers = new ArrayList<StopwordsHandler>();
do {
tmpStr = Utils.getOption("stopwords", options);
if (!tmpStr.isEmpty()) {
tmpOptions = Utils.splitOptions(tmpStr);
tmpStr = tmpOptions[0];
tmpOptions[0] = "";
handlers.add((StopwordsHandler) Utils.forName(StopwordsHandler.class, tmpStr, tmpOptions));
}
}
while (!tmpStr.isEmpty());
setStopwords(handlers.toArray(new StopwordsHandler[handlers.size()]));
super.setOptions(options);
}
示例7: getObject
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Tries to instantiate the class stored for this property, optional options
* will be set as well. Returns null if unsuccessful.
*
* @param property the property to get the object for
* @param defaultValue the default object spec string
* @param cls the class the object must be derived from
* @return if successful the fully configured object, null otherwise
*/
protected static Object getObject(String property, String defaultValue,
Class<?> cls) {
Object result;
String tmpStr;
String[] tmpOptions;
result = null;
try {
tmpStr = get(property, defaultValue);
tmpOptions = Utils.splitOptions(tmpStr);
if (tmpOptions.length != 0) {
tmpStr = tmpOptions[0];
tmpOptions[0] = "";
result = Utils.forName(cls, tmpStr, tmpOptions);
}
} catch (Exception e) {
e.printStackTrace();
result = null;
}
return result;
}
示例8: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
@Override
public void setOptions(String[] options) throws Exception {
setDontReplaceMissingValues(Utils.getFlag("dont-replace-missing", options));
m_filtersToUse = new ArrayList<Filter>();
while (true) {
String filterString = Utils.getOption("filter", options);
if (DistributedJobConfig.isEmpty(filterString)) {
break;
}
String[] spec = Utils.splitOptions(filterString);
if (spec.length == 0) {
throw new IllegalArgumentException(
"Invalid filter specification string");
}
String filterClass = spec[0];
Filter f = (Filter) Class.forName(filterClass).newInstance();
spec[0] = "";
if (f instanceof OptionHandler) {
((OptionHandler) f).setOptions(spec);
}
m_filtersToUse.add(f);
}
}
示例9: SelectAttributes
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Perform attribute selection with a particular evaluator and a set of
* options specifying search method and input file etc.
*
* @param ASEvaluator an evaluator object
* @param options an array of options, not only for the evaluator but also the
* search method (if any) and an input data file
* @return the results of attribute selection as a String
* @exception Exception if no training file is set
*/
public static String SelectAttributes(ASEvaluation ASEvaluator,
String[] options) throws Exception {
String trainFileName, searchName;
Instances train = null;
ASSearch searchMethod = null;
String[] optionsTmp = options.clone();
boolean helpRequested = false;
try {
// get basic options (options the same for all attribute selectors
trainFileName = Utils.getOption('i', options);
helpRequested = Utils.getFlag('h', optionsTmp);
if (helpRequested || (trainFileName.length() == 0)) {
searchName = Utils.getOption('s', optionsTmp);
if (searchName.length() != 0) {
String[] searchOptions = Utils.splitOptions(searchName);
searchMethod =
(ASSearch) Class.forName(searchOptions[0]).newInstance();
}
if (helpRequested) {
throw new Exception("Help requested.");
} else {
throw new Exception("No training file given.");
}
}
} catch (Exception e) {
throw new Exception('\n' + e.getMessage()
+ makeOptionString(ASEvaluator, searchMethod));
}
DataSource source = new DataSource(trainFileName);
train = source.getDataSet();
return SelectAttributes(ASEvaluator, options, train);
}
示例10: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Parses a given list of options. <p/>
*
<!-- options-start -->
<!-- options-end -->
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
public void setOptions(String[] options) throws Exception {
String binsString = Utils.getOption('B', options);
if (binsString.length() != 0) {
setNumBins(Integer.parseInt(binsString));
} else {
setNumBins(10);
}
setDeleteEmptyBins(Utils.getFlag('E', options));
setUseEqualFrequency(Utils.getFlag('F', options));
setMinimizeAbsoluteError(Utils.getFlag('A', options));
String tmpStr = Utils.getOption('K', options);
String[] tmpOptions = Utils.splitOptions(tmpStr);
if (tmpOptions.length != 0) {
tmpStr = tmpOptions[0];
tmpOptions[0] = "";
setEstimator(((UnivariateDensityEstimator) Utils.forName(UnivariateDensityEstimator.class,
tmpStr, tmpOptions)));
}
super.setOptions(options);
Utils.checkForRemainingOptions(options);
}
示例11: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Parses a given list of options. <p/>
*
<!-- options-start -->
* Valid options are: <p/>
*
* <pre> -S <classname and options>
* Node splitting method to use.
* (default: weka.core.neighboursearch.kdtrees.SlidingMidPointOfWidestSide)</pre>
*
* <pre> -W <value>
* Set minimal width of a box
* (default: 1.0E-2).</pre>
*
* <pre> -L
* Maximal number of instances in a leaf
* (default: 40).</pre>
*
* <pre> -N
* Normalizing will be done
* (Select dimension for split, with normalising to universe).</pre>
*
<!-- options-end -->
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
public void setOptions(String[] options) throws Exception {
super.setOptions(options);
String optionString = Utils.getOption('S', options);
if (optionString.length() != 0) {
String splitMethodSpec[] = Utils.splitOptions(optionString);
if (splitMethodSpec.length == 0) {
throw new Exception("Invalid DistanceFunction specification string.");
}
String className = splitMethodSpec[0];
splitMethodSpec[0] = "";
setNodeSplitter((KDTreeNodeSplitter) Utils.forName(
KDTreeNodeSplitter.class, className, splitMethodSpec));
}
else {
setNodeSplitter(new SlidingMidPointOfWidestSide());
}
optionString = Utils.getOption('W', options);
if (optionString.length() != 0)
setMinBoxRelWidth(Double.parseDouble(optionString));
else
setMinBoxRelWidth(1.0E-2);
optionString = Utils.getOption('L', options);
if (optionString.length() != 0)
setMaxInstInLeaf(Integer.parseInt(optionString));
else
setMaxInstInLeaf(40);
setNormalizeNodeWidth(Utils.getFlag('N', options));
Utils.checkForRemainingOptions(options);
}
示例12: processMetaOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Process options setting meta classifier.
*
* @param options the options to parse
* @throws Exception if the parsing fails
*/
protected void processMetaOptions(String[] options) throws Exception {
String classifierString = Utils.getOption('M', options);
String [] classifierSpec = Utils.splitOptions(classifierString);
String classifierName;
if (classifierSpec.length == 0) {
classifierName = "weka.classifiers.rules.ZeroR";
} else {
classifierName = classifierSpec[0];
classifierSpec[0] = "";
}
setMetaClassifier(AbstractClassifier.forName(classifierName, classifierSpec));
}
示例13: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
@Override
public void setOptions(String[] options) throws Exception {
m_config = new HDFSConfig();
String path = Utils.getOption("dest", options); //$NON-NLS-1$
if (!DistributedJobConfig.isEmpty(path)) {
setHDFSPath(path);
}
String factor = Utils.getOption("dfs-replication", options); //$NON-NLS-1$
if (!DistributedJobConfig.isEmpty(factor)) {
setDFSReplicationFactor(factor);
}
String saverSpec = Utils.getOption("saver", options); //$NON-NLS-1$
if (!DistributedJobConfig.isEmpty(saverSpec)) {
String[] split = Utils.splitOptions(saverSpec);
String saverClass = split[0];
split[0] = ""; //$NON-NLS-1$
AbstractFileSaver s = (AbstractFileSaver) Utils.forName(
AbstractFileSaver.class, saverClass, split);
setSaver(s);
}
m_config.setOptions(options);
}
示例14: buildAssociations
import weka.core.Utils; //导入方法依赖的package包/类
private void buildAssociations(Instances data) throws Exception {
// see if there is an environment variable with
// options for the associator
if (m_env != null && m_Associator instanceof OptionHandler) {
String opts = m_env
.getVariableValue("weka.gui.beans.associator.schemeOptions");
if (opts != null && opts.length() > 0) {
String[] options = Utils.splitOptions(opts);
if (options.length > 0) {
try {
((OptionHandler) m_Associator).setOptions(options);
} catch (Exception ex) {
String warningMessage = "[Associator] WARNING: unable to set options \""
+ opts + "\"for " + m_Associator.getClass().getName();
if (m_log != null) {
m_log.logMessage(warningMessage);
} else {
System.err.print(warningMessage);
}
}
}
}
}
m_Associator.buildAssociations(data);
}
示例15: setOptions
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Parses a given list of options. <p/>
*
<!-- options-start -->
* Valid options are: <p/>
*
* <pre> -W <classname and options>
* The classifier (incl. options) that was used to generate
* the source code.</pre>
*
* <pre> -S <classname>
* The classname of the generated source code.</pre>
*
* <pre> -t <file>
* The training set with which the source code was generated.</pre>
*
* <pre> -c <index>
* The class index of the training set. 'first' and 'last' are
* valid indices.
* (default: last)</pre>
*
<!-- options-end -->
*
* Options after -- are passed to the designated classifier (specified with
* -W).
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
public void setOptions(String[] options) throws Exception {
String tmpStr;
String[] spec;
String classname;
tmpStr = Utils.getOption('W', options);
if (tmpStr.length() > 0) {
spec = Utils.splitOptions(tmpStr);
if (spec.length == 0)
throw new IllegalArgumentException("Invalid classifier specification string");
classname = spec[0];
spec[0] = "";
setClassifier((Classifier) Utils.forName(Classifier.class, classname, spec));
}
else {
throw new Exception("No classifier (classname + options) provided!");
}
tmpStr = Utils.getOption('S', options);
if (tmpStr.length() > 0) {
spec = Utils.splitOptions(tmpStr);
if (spec.length != 1)
throw new IllegalArgumentException("Invalid source code specification string");
classname = spec[0];
spec[0] = "";
setSourceCode((Classifier) Utils.forName(Classifier.class, classname, spec));
}
else {
throw new Exception("No source code (classname) provided!");
}
tmpStr = Utils.getOption('t', options);
if (tmpStr.length() != 0)
setDataset(new File(tmpStr));
else
throw new Exception("No dataset provided!");
tmpStr = Utils.getOption('c', options);
if (tmpStr.length() != 0) {
if (tmpStr.equals("first"))
setClassIndex(0);
else if (tmpStr.equals("last"))
setClassIndex(-1);
else
setClassIndex(Integer.parseInt(tmpStr) - 1);
}
else {
setClassIndex(-1);
}
}