下面列出了怎么用weka.core.Option的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector newVector = new Vector(4);
newVector.addElement(new Option(
"\tSpecify list of columns to transform. First and last are\n"
+ "\tvalid indexes (default none). Non-numeric columns are \n"
+ "\tskipped.",
"R", 1, "-R <index1,index2-index4,...>"));
newVector.addElement(new Option(
"\tInvert matching sense.",
"V", 0, "-V"));
newVector.addElement(new Option(
"\tSets the class containing transformation method.\n"+
"\t(default java.lang.Math)",
"C", 1, "-C <string>"));
newVector.addElement(new Option(
"\tSets the method. (default abs)",
"M", 1, "-M <string>"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector<Option> result;
Enumeration enm;
result = new Vector<Option>();
enm = super.listOptions();
while (enm.hasMoreElements())
result.addElement((Option)enm.nextElement());
result.addElement(new Option("\tThe minimum frequency for a value to remain (default: 2).\n",
"-N", 1, "-N <int>"));
result.addElement(new Option(
"\tSets list of attributes to act on (or its inverse). 'first and 'last' are accepted as well.'\n"
+ "\tE.g.: first-5,7,9,20-last\n"
+ "\t(default: 1,2)",
"R", 1, "-R <range>"));
result.addElement(new Option(
"\tInvert matching sense (i.e. act on all attributes not specified in list)",
"V", 0, "-V"));
return result.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector result = new Vector();
result.addElement(new Option(
"\tSpecify the random number seed (default 1)",
"S", 1, "-S <num>"));
result.addElement(new Option(
"\tThe size of the output dataset, as a percentage of\n"
+"\tthe input dataset (default 100)",
"Z", 1, "-Z <num>"));
result.addElement(new Option(
"\tDisables replacement of instances\n"
+"\t(default: with replacement)",
"no-replacement", 0, "-no-replacement"));
result.addElement(new Option(
"\tInverts the selection - only available with '-no-replacement'.",
"V", 0, "-V"));
return result.elements();
}
/**
* Executes the tests, use "-h" to list the commandline options.
*
* @param args the commandline parameters
* @throws Exception if something goes wrong
*/
public static void main(String[] args) throws Exception{
CheckSource check;
StringBuffer text;
Enumeration enm;
check = new CheckSource();
if (Utils.getFlag('h', args)) {
text = new StringBuffer();
text.append("\nHelp requested:\n\n");
enm = check.listOptions();
while (enm.hasMoreElements()) {
Option option = (Option) enm.nextElement();
text.append(option.synopsis() + "\n");
text.append(option.description() + "\n");
}
System.out.println("\n" + text + "\n");
}
else {
check.setOptions(args);
if (check.execute())
System.out.println("Tests OK!");
else
System.out.println("Tests failed!");
}
}
/**
* Lists the available options
*
* @return an enumeration of the available options
*/
public Enumeration listOptions() {
Vector<Option> result = new Vector<Option>();
result.add(new Option(
"\tEnables debug output.\n"
+ "\t(default: off)",
"D", 0, "-D"));
result.add(new Option(
"\tStores the filename in an additional attribute.\n"
+ "\t(default: off)",
"F", 0, "-F"));
result.add(new Option(
"\tThe directory to work on.\n"
+ "\t(default: current directory)",
"dir", 0, "-dir <directory>"));
result.add(new Option("\tThe character set to use, e.g UTF-8.\n\t" +
"(default: use the default character set)", "charset", 1,
"-charset <charset name>"));
return result.elements();
}
/**
* Returns an enumeration of all the available options..
*
* @return an enumeration of all available options.
*/
public Enumeration listOptions(){
Vector newVector = new Vector(2);
newVector.addElement(new Option(
"\tNumber of attempts of generalisation.\n",
"G",
1,
"-G <value>"));
newVector.addElement(new Option(
"\tNumber of folder for computing the mutual information.\n",
"I",
1,
"-I <value>"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector newVector = new Vector(2);
newVector.addElement(new Option("\tMaximum number of parents", "P", 1, "-P <nr of parents>"));
newVector.addElement(new Option("\tUse arc reversal operation.\n\t(default false)", "R", 0, "-R"));
newVector.addElement(new Option("\tInitial structure is empty (instead of Naive Bayes)", "N", 0, "-N"));
newVector.addElement(new Option("\tInitial structure specified in XML BIF file", "X", 1, "-X"));
Enumeration enu = super.listOptions();
while (enu.hasMoreElements()) {
newVector.addElement(enu.nextElement());
}
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
Vector<Option> result = new Vector<>();
result.addElement(new Option(
"\tIf set, generator is run in debug mode and\n"
+ "\tmay output additional info to the console",
"output-debug-info", 0, "-output-debug-info"));
return result.elements();
}
/**
* Returns an enumeration describing the available options.
*
* Valid options are: <p>
*
* -U <br>
* Use unpruned tree.<p>
*
* -C confidence <br>
* Set confidence threshold for pruning. (Default: 0.25) <p>
*
* -M number <br>
* Set minimum number of instances per leaf. (Default: 2) <p>
*
* -B <br>
* Use binary splits for nominal attributes. <p>
*
* -S <br>
* Don't perform subtree raising. <p>
*
* -L <br>
* Do not clean up after the tree has been built.
*
* -A <br>
* If set, Laplace smoothing is used for predicted probabilites.
* (note: this option only affects initial tree; grafting process always uses laplace). <p>
*
* -E <br>
* Allow relabelling when grafting. <p>
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector newVector = new Vector(9);
newVector.
addElement(new Option("\tUse unpruned tree.",
"U", 0, "-U"));
newVector.
addElement(new Option("\tSet confidence threshold for pruning.\n" +
"\t(default 0.25)",
"C", 1, "-C <pruning confidence>"));
newVector.
addElement(new Option("\tSet minimum number of instances per leaf.\n" +
"\t(default 2)",
"M", 1, "-M <minimum number of instances>"));
newVector.
addElement(new Option("\tUse binary splits only.",
"B", 0, "-B"));
newVector.
addElement(new Option("\tDon't perform subtree raising.",
"S", 0, "-S"));
newVector.
addElement(new Option("\tDo not clean up after the tree has been built.",
"L", 0, "-L"));
newVector.
addElement(new Option("\tLaplace smoothing for predicted probabilities. (note: this option only affects initial tree; grafting process always uses laplace).",
"A", 0, "-A"));
newVector.
addElement(new Option("\tRelabel when grafting.",
"E", 0, "-E"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
Vector<Option> newVector = new Vector<Option>();
newVector.add(new Option("\tSet the loss function to minimize.\n\t0 = "
+ "hinge loss (SVM), 1 = log loss (logistic regression),\n\t"
+ "2 = squared loss (regression), 3 = epsilon insensitive loss (regression)," +
"\n\t4 = Huber loss (regression).\n\t(default = 0)", "F", 1, "-F"));
newVector
.add(new Option(
"\tThe learning rate. If normalization is\n"
+ "\tturned off (as it is automatically for streaming data), then the\n\t"
+ "default learning rate will need to be reduced "
+ "(try 0.0001).\n\t(default = 0.01).", "L", 1, "-L"));
newVector.add(new Option("\tThe lambda regularization constant "
+ "(default = 0.0001)", "R", 1, "-R <double>"));
newVector.add(new Option("\tThe number of epochs to perform ("
+ "batch learning only, default = 500)", "E", 1, "-E <integer>"));
newVector.add(new Option("\tThe epsilon threshold ("
+ "epsilon-insenstive and Huber loss only, default = 1e-3)", "C", 1,
"-C <double>"));
newVector.add(new Option("\tDon't normalize the data", "N", 0, "-N"));
newVector.add(new Option("\tDon't replace missing values", "M", 0, "-M"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
* @return an enumeration of all the available options.
**/
public Enumeration listOptions () {
Vector newVector = new Vector(4);
newVector
.addElement(new Option("\tSpecify the number of instances to\n"
+ "\tsample when estimating attributes.\n"
+ "\tIf not specified, then all instances\n"
+ "\twill be used.", "M", 1
, "-M <num instances>"));
newVector.
addElement(new Option("\tSeed for randomly sampling instances.\n"
+ "\t(Default = 1)", "D", 1
, "-D <seed>"));
newVector.
addElement(new Option("\tNumber of nearest neighbours (k) used\n"
+ "\tto estimate attribute relevances\n"
+ "\t(Default = 10).", "K", 1
, "-K <number of neighbours>"));
newVector.
addElement(new Option("\tWeight nearest neighbours by distance", "W"
, 0, "-W"));
newVector.
addElement(new Option("\tSpecify sigma value (used in an exp\n"
+ "\tfunction to control how quickly\n"
+ "\tweights for more distant instances\n"
+ "\tdecrease. Use in conjunction with -W.\n"
+ "\tSensible value=1/5 to 1/10 of the\n"
+ "\tnumber of nearest neighbours.\n"
+ "\t(Default = 2)", "A", 1, "-A <num>"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
* @return an enumeration of all the available options.
**/
public Enumeration listOptions () {
Vector newVector = new Vector(2);
newVector.addElement(new Option("\ttreat missing values as a seperate "
+ "value.", "M", 0, "-M"));
newVector.addElement(new Option("\tjust binarize numeric attributes instead \n"
+"\tof properly discretizing them.", "B", 0,
"-B"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*
*/
public Enumeration listOptions() {
Vector newVector = new Vector(8);
newVector.addElement(new Option("\tSpecify a starting set of attributes." +
"\n\tEg. 1,3,5-7.", "P", 1, "-P <start set>"));
newVector.addElement(new Option(
"\tForward selection method. (default = 0).", "D", 1,
"-D <0 = forward selection | 1 = floating forward selection>"));
newVector.addElement(new Option("\tNumber of non-improving nodes to" +
"\n\tconsider before terminating search.", "N", 1, "-N <num>"));
newVector.addElement(new Option("\tPerform initial ranking to select the" +
"\n\ttop-ranked attributes.", "I", 0, "-I"));
newVector.addElement(new Option(
"\tNumber of top-ranked attributes that are " +
"\n\ttaken into account by the search.", "K", 1, "-K <num>"));
newVector.addElement(new Option(
"\tType of Linear Forward Selection (default = 0).", "T", 1,
"-T <0 = fixed-set | 1 = fixed-width>"));
newVector.addElement(new Option(
"\tSize of lookup cache for evaluated subsets." +
"\n\tExpressed as a multiple of the number of" +
"\n\tattributes in the data set. (default = 1)", "S", 1, "-S <num>"));
newVector.addElement(new Option("\tverbose on/off", "Z", 0, "-Z"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options
*
* @return an enumeration of all the available options
*/
public Enumeration listOptions() {
Vector newVector = new Vector(4);
newVector.addElement(new Option("\tTurn on debugging output.",
"D", 0, "-D"));
newVector.addElement(new Option("\tUse conjugate gradient descent rather than BFGS updates.",
"C", 0, "-C"));
newVector.addElement(new Option("\tSet the ridge in the log-likelihood.",
"R", 1, "-R <ridge>"));
newVector.addElement(new Option("\tSet the maximum number of iterations"+
" (default -1, until convergence).",
"M", 1, "-M <number>"));
return newVector.elements();
}
@Override
public Enumeration listOptions() {
Vector result = new Vector();
result.addElement(new Option("\tSets the number of hidden units\n\tdefault: 10", "H", 1, "-H <value>"));
result.addElement(new Option("\tSets the maximum number of epochs\n\tdefault: 1000\t(auto-cut-out)", "E", 1, "-E <value>"));
result.addElement(new Option("\tSets the learning rate (tyically somewhere between 'very small' and 0.1)\n\tdefault: 0.1", "r", 1, "-r <value>"));
result.addElement(new Option("\tSets the momentum (typically somewhere between 0.1 and 0.9)\n\tdefault: 0.1", "m", 1, "-m <value>"));
OptionUtils.add(result, super.listOptions());
return OptionUtils.toEnumeration(result);
}
/**
* Checks whether the scheme can take command line options.
*
* @return index 0 is true if the scheme can take options
*/
protected boolean[] canTakeOptions() {
boolean[] result = new boolean[2];
print("options...");
if (getTestObject() instanceof OptionHandler) {
println("yes");
if (m_Debug) {
println("\n=== Full report ===");
Enumeration enu = ((OptionHandler) getTestObject()).listOptions();
while (enu.hasMoreElements()) {
Option option = (Option) enu.nextElement();
print(option.synopsis() + "\n"
+ option.description() + "\n");
}
println("\n");
}
result[0] = true;
}
else {
println("no");
result[0] = false;
}
return result;
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options
*/
public Enumeration listOptions() {
Vector result = enumToVector(super.listOptions());
result.addElement(new Option(
"\tThe noise rate in percent (default "
+ defaultNoiseRate() + ").\n"
+ "\tCan be between 0% and 30%. (Remark: The original \n"
+ "\talgorithm only allows noise up to 10%.)",
"P", 1, "-P <num>"));
result.addElement(new Option(
"\tA cluster definition of class '"
+ SubspaceClusterDefinition.class.getName().replaceAll(".*\\.", "") + "'\n"
+ "\t(definition needs to be quoted to be recognized as \n"
+ "\ta single argument).",
"C", 1, "-C <cluster-definition>"));
result.addElement(new Option(
"", "", 0,
"\nOptions specific to "
+ SubspaceClusterDefinition.class.getName() + ":"));
result.addAll(
enumToVector(new SubspaceClusterDefinition(this).listOptions()));
return result.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector newVector = new Vector(2);
newVector.addElement(new Option(
"\tSpecify list of columns to delete. First and last are valid\n"
+"\tindexes. (default none)",
"R", 1, "-R <index1,index2-index4,...>"));
newVector.addElement(new Option(
"\tInvert matching sense (i.e. only keep specified columns)",
"V", 0, "-V"));
return newVector.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
Vector<Option> result = new Vector<>();
Enumeration<Option> enm = super.listOptions();
while (enm.hasMoreElements())
result.add(enm.nextElement());
result.addElement(new Option(
"\tIf set, title is skipped in the output",
"skip-title", 0, "-skip-title"));
return result.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration listOptions() {
Vector<Option> result;
result = new Vector<Option>();
Enumeration en = super.listOptions();
while (en.hasMoreElements())
result.addElement((Option)en.nextElement());
result.addElement(
new Option(
"\tThe class index (first and last are valid as well).\n"
+ "\t(default: last)",
"C", 1, "-C <class index>"));
result.addElement(
new Option(
"\tCompresses the data (uses '"
+ XRFFLoader.FILE_EXTENSION_COMPRESSED
+ "' as extension instead of '"
+ XRFFLoader.FILE_EXTENSION + "')\n"
+ "\t(default: off)",
"compress", 0, "-compress"));
return result.elements();
}
@Override
public Enumeration listOptions() {
Vector result = new Vector();
result.addElement(new Option("\tThe population size (of chains) -- should be smaller than the total number of chains evaluated (Is) \n\tdefault: 10", "M", 1, "-M <value>"));
result.addElement(new Option("\tUse temperature: cool the chain down over time (from the beginning of the chain) -- can be faster\n\tdefault: 0 (no temperature)", "O", 1, "-O <value>"));
result.addElement(new Option("\tIf using O = 1 for temperature, this sets the Beta constant \n\tdefault: 0.03", "B", 1, "-B <value>"));
OptionUtils.add(result, super.listOptions());
return OptionUtils.toEnumeration(result);
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options
*/
public Enumeration listOptions() {
Vector newVector = new Vector();
newVector.addElement(new Option(
"\tNumber of trees to build.",
"I", 1, "-I <number of trees>"));
newVector.addElement(new Option(
"\tNumber of features to consider (<1=int(logM+1)).",
"K", 1, "-K <number of features>"));
newVector.addElement(new Option(
"\tSeed for random number generator.\n"
+ "\t(default 1)",
"S", 1, "-S"));
newVector.addElement(new Option(
"\tThe maximum depth of the trees, 0 for unlimited.\n"
+ "\t(default 0)",
"depth", 1, "-depth <num>"));
newVector.addElement(new Option(
"\tPrint the individual trees in the output", "print", 0, "-print"));
newVector.addElement(new Option(
"\tNumber of execution slots.\n"
+ "\t(default 1 - i.e. no parallelism)",
"num-slots", 1, "-num-slots <num>"));
Enumeration enu = super.listOptions();
while (enu.hasMoreElements()) {
newVector.addElement(enu.nextElement());
}
return newVector.elements();
}
/**
* Returns an enumeration describing the available options
*
* @return an enumeration of all the available options
*/
public Enumeration listOptions() {
Vector newVector = new Vector(6);
newVector.addElement(new Option("\tGenerate network (instead of instances)\n", "B", 0, "-B"));
newVector.addElement(new Option("\tNr of nodes\n", "N", 1, "-N <integer>"));
newVector.addElement(new Option("\tNr of arcs\n", "A", 1, "-A <integer>"));
newVector.addElement(new Option("\tNr of instances\n", "M", 1, "-M <integer>"));
newVector.addElement(new Option("\tCardinality of the variables\n", "C", 1, "-C <integer>"));
newVector.addElement(new Option("\tSeed for random number generator\n", "S", 1, "-S <integer>"));
newVector.addElement(new Option("\tThe BIF file to obtain the structure from.\n", "F", 1, "-F <file>"));
return newVector.elements();
}
/**
* Returns an enumeration of all the available options..
*
* @return an enumeration of all available options.
*/
@Override
public Enumeration<Option> listOptions() {
Vector result = new Vector();
OptionUtils.add(result, super.listOptions());
OptionUtils.addOption(result, numFoldsTipText(), "" + getDefaultNumFolds(), 'F');
OptionUtils.addFlag(result, preserveOrderTipText(), 'O');
OptionUtils.addOption(result, seedTipText(), "" + getDefaultSeed(), 'S');
OptionUtils.addOption(result, thresholdTipText(), "" + getDefaultThreshold(), 'T');
OptionUtils.addOption(result, verbosityTipText(), "" + getDefaultVerbosity(), 'V');
OptionUtils.addOption(result, numThreadsTipText(), "" + getDefaultNumThreads(), "num-threads");
return OptionUtils.toEnumeration(result);
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
return Option.listOptionsForClass(this.getClass()).elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration listOptions() {
Vector result = new Vector();
result.addElement(new Option("\tnumber of clusters.\n" + "\t(default 2).",
"N", 1, "-N <num>"));
result.addElement(new Option("\tInitialize using the k-means++ method.\n",
"P", 0, "-P"));
result.addElement(new Option("\tDisplay std. deviations for centroids.\n",
"V", 0, "-V"));
result.addElement(new Option("\tDon't replace missing values with mean/mode.\n",
"M", 0, "-M"));
result.add(new Option("\tDistance function to use.\n"
+ "\t(default: weka.core.EuclideanDistance)", "A", 1,
"-A <classname and options>"));
result.add(new Option("\tMaximum number of iterations.\n", "I", 1,
"-I <num>"));
result.addElement(new Option("\tPreserve order of instances.\n", "O", 0,
"-O"));
result
.addElement(new Option(
"\tEnables faster distance calculations, using cut-off values.\n"
+ "\tDisables the calculation/output of squared errors/distances.\n",
"fast", 0, "-fast"));
result.addElement(new Option("\tNumber of execution slots.\n"
+ "\t(default 1 - i.e. no parallelism)", "num-slots", 1,
"-num-slots <num>"));
Enumeration en = super.listOptions();
while (en.hasMoreElements())
result.addElement(en.nextElement());
return result.elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
return Option.listOptionsForClass(this.getClass()).elements();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
return Option.listOptionsForClass(this.getClass()).elements();
}
/**
* Gets the current settings of the Classifier.
*
* @return an array of strings suitable for passing to setOptions
*/
@Override
public String[] getOptions() {
return Option.getOptions(this, this.getClass());
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration<Option> listOptions() {
return Option.listOptionsForClass(this.getClass()).elements();
}