/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -folds <folds> * The number of folds for splitting the training set into * train and test set. The first fold is always the training * set. With '-V' you can invert this, i.e., instead of 20/80 * for 5 folds you'll get 80/20. * (default 5)</pre> * * <pre> -V * Inverts the fold selection, i.e., instead of using the first * fold for the training set it is used for test set and the * remaining folds for training.</pre> * * <pre> -verbose * Whether to print some more information during building the * classifier. * (default is off)</pre> * * <pre> -insight * Whether to use the labels of the original test set for more * statistics (not used for learning!). * (default is off)</pre> * * <pre> -S <num> * Random number seed. * (default 1)</pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <pre> -naive * Uses a sorted list (ordered according to distance) instead of the * KDTree for finding the neighbors. * (default is KDTree)</pre> * * <pre> -I * Weight neighbours by the inverse of their distance * (use when k > 1)</pre> * * <pre> -F * Weight neighbours by 1 - their distance * (use when k > 1)</pre> * * <pre> -K <number of neighbors> * Number of nearest neighbours (k) used in classification. * (Default = 1)</pre> * * <pre> -A * The nearest neighbour search algorithm to use (default: LinearNN). * </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); setUseNaiveSearch(Utils.getFlag("naive", options)); m_Classifier.setOptions(options); m_KNN = m_Classifier.getKNN(); // backup KNN m_Classifier.setCrossValidate(true); // always on! m_Classifier.setWindowSize(0); // always off! m_Classifier.setMeanSquared(false); // always off! }
/** * Parses a given list of options. Valid options are: * * <p>-D <br> * If set, clusterer is run in debug mode and may output additional info to the console. * * <p>-do-not-check-capabilities <br> * If set, clusterer capabilities are not checked before clusterer is built (use with caution). * * <p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { Option.setOptionsForHierarchy(options, this, AbstractClusterer.class); setDebug(Utils.getFlag("output-debug-info", options)); setDoNotCheckCapabilities(Utils.getFlag("do-not-check-capabilities", options)); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -find <regexp> * The regular expression that the attribute names must match. * (default: ([\s\S]+))</pre> * * <pre> -replace <string> * The string to replace the regular expression of matching attributes with. * Cannot be used in conjunction with '-remove'. * (default: $0)</pre> * * <pre> -remove * In case the matching string needs to be removed instead of replaced. * Cannot be used in conjunction with '-replace <string>'. * (default: off)</pre> * * <pre> -all * Replaces all occurrences instead of just the first. * (default: only first occurrence)</pre> * * <pre> -R <range> * The attribute range to work on. * This is a comma separated list of attribute indices, with "first" and "last" valid values. * Specify an inclusive range with "-". * E.g: "first-3,5,6-10,last". * (default: first-last)</pre> * * <pre> -V * Inverts the attribute selection range. * (default: off)</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 { String tmpStr; tmpStr = Utils.getOption("find", options); if (tmpStr.length() != 0) setFind(tmpStr); else setFind("([\\s\\S]+)"); if (Utils.getFlag("remove", options)) { setReplace(""); } else { tmpStr = Utils.getOption("replace", options); if (tmpStr.length() > 0) setReplace(tmpStr); else setReplace("$0"); } setReplaceAll(Utils.getFlag("all", options)); tmpStr = Utils.getOption("R", options); if (tmpStr.length() != 0) setAttributeIndices(tmpStr); else setAttributeIndices("first-last"); setInvertSelection(Utils.getFlag("V", options)); if (getInputFormat() != null) setInputFormat(getInputFormat()); }
/** * Parses a given list of options controlling the behaviour of this object. Valid options are: * * <p>-l "directory name"<br> * Specifies name of directory. * * <p>-m "model name"<br> * Specifies name of model. * * <p>-e "encoding"<br> * Specifies encoding. * * <p>-n<br> * Specifies number of phrases to be output (default: 5). * * <p>-d<br> * Turns debugging mode on. * * <p>-a<br> * Also write stemmed phrase and score into ".key" file. * * <p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String dirName = Utils.getOption('l', options); if (dirName.length() > 0) { setDirName(dirName); } else { setDirName(null); throw new Exception("Name of directory required argument."); } String modelName = Utils.getOption('m', options); if (modelName.length() > 0) { setModelName(modelName); } else { setModelName(null); throw new Exception("Name of model required argument."); } String encoding = Utils.getOption('e', options); if (encoding.length() > 0) { setEncoding(encoding); } else { setEncoding("default"); } String numPhrases = Utils.getOption('n', options); if (numPhrases.length() > 0) { setNumPhrases(Integer.parseInt(numPhrases)); } else { setNumPhrases(5); } setDebug(Utils.getFlag('d', options)); setAdditionalInfo(Utils.getFlag('a', options)); Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -R <col1,col2-col4,...> * Specifies list of columns to Discretize. First and last are valid indexes. * (default none)</pre> * * <pre> -V * Invert matching sense of column indexes.</pre> * * <pre> -D * Output binary attributes for discretized attributes.</pre> * * <pre> -Y * Use bin numbers rather than ranges for discretized attributes.</pre> * * <pre> -E * Use better encoding of split point for MDL.</pre> * * <pre> -K * Use Kononenko's MDL criterion.</pre> * * <pre> -precision <integer> * Precision for bin boundary labels. * (default = 6 decimal places).</pre> * * <!-- 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 { setMakeBinary(Utils.getFlag('D', options)); setUseBinNumbers(Utils.getFlag('Y', options)); setUseBetterEncoding(Utils.getFlag('E', options)); setUseKononenko(Utils.getFlag('K', options)); setInvertSelection(Utils.getFlag('V', options)); String convertList = Utils.getOption('R', options); if (convertList.length() != 0) { setAttributeIndices(convertList); } else { setAttributeIndices("first-last"); } String precisionS = Utils.getOption("precision", options); if (precisionS.length() > 0) { setBinRangePrecision(Integer.parseInt(precisionS)); } if (getInputFormat() != null) { setInputFormat(getInputFormat()); } Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -B * Binary splits (convert nominal attributes to binary ones) </pre> * * <pre> -P * Use error on probabilities instead of misclassification error for stopping criterion of LogitBoost. * </pre> * * <pre> -I <numIterations> * Set fixed number of iterations for LogitBoost (instead of using cross-validation)</pre> * * <pre> -F <modelType> * Set Funtional Tree type to be generate: 0 for FT, 1 for FTLeaves and 2 for FTInner</pre> * * <pre> -M <numInstances> * Set minimum number of instances at which a node can be split (default 15)</pre> * * <pre> -W <beta> * Set beta for weight trimming for LogitBoost. Set to 0 (default) for no weight trimming.</pre> * * <pre> -A * The AIC is used to choose the best iteration.</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 { setBinSplit(Utils.getFlag('B', options)); setErrorOnProbabilities(Utils.getFlag('P', options)); String optionString = Utils.getOption('I', options); if (optionString.length() != 0) { setNumBoostingIterations((new Integer(optionString)).intValue()); } optionString = Utils.getOption('F', options); if (optionString.length() != 0) { setModelType(new SelectedTag(Integer.parseInt(optionString), TAGS_MODEL)); // setModelType((new Integer(optionString)).intValue()); } optionString = Utils.getOption('M', options); if (optionString.length() != 0) { setMinNumInstances((new Integer(optionString)).intValue()); } optionString = Utils.getOption('W', options); if (optionString.length() != 0) { setWeightTrimBeta((new Double(optionString)).doubleValue()); } setUseAIC(Utils.getFlag('A', options)); Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -C * Set whether or not use empirical * log-odds cut-off instead of 0</pre> * * <pre> -R <numOfRuns> * Set the number of multiple runs * needed for searching the MLE.</pre> * * <pre> -S <num> * Random number seed. * (default 1)</pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</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 { setDebug(Utils.getFlag('D', options)); setUsingCutOff(Utils.getFlag('C', options)); String runString = Utils.getOption('R', options); if (runString.length() != 0) setNumRuns(Integer.parseInt(runString)); else setNumRuns(1); super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> * -C <pruning confidence> * Set confidence threshold for pruning. * (default 0.25) * </pre> * * <pre> * -M <minimum number of objects> * Set minimum number of objects per leaf. * (default 2) * </pre> * * <pre> * -R * Use reduced error pruning. * </pre> * * <pre> * -N <number of folds> * Set number of folds for reduced error * pruning. One fold is used as pruning set. * (default 3) * </pre> * * <pre> * -B * Use binary splits only. * </pre> * * <pre> * -U * Generate unpruned decision list. * </pre> * * <pre> * -J * Do not use MDL correction for info gain on numeric attributes. * </pre> * * <pre> * -Q <seed> * Seed for random data shuffling (default 1). * </pre> * * <pre> * -doNotMakeSplitPointActualValue * Do not make split point actual value. * </pre> * * <!-- 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 { // Pruning options m_unpruned = Utils.getFlag('U', options); m_reducedErrorPruning = Utils.getFlag('R', options); m_binarySplits = Utils.getFlag('B', options); m_useMDLcorrection = !Utils.getFlag('J', options); m_doNotMakeSplitPointActualValue = Utils.getFlag("doNotMakeSplitPointActualValue", options); String confidenceString = Utils.getOption('C', options); if (confidenceString.length() != 0) { if (m_reducedErrorPruning) { throw new Exception("Setting CF doesn't make sense " + "for reduced error pruning."); } else { m_CF = (new Float(confidenceString)).floatValue(); if ((m_CF <= 0) || (m_CF >= 1)) { throw new Exception("CF has to be greater than zero and smaller than one!"); } } } else { m_CF = 0.25f; } String numFoldsString = Utils.getOption('N', options); if (numFoldsString.length() != 0) { if (!m_reducedErrorPruning) { throw new Exception( "Setting the number of folds" + " does only make sense for" + " reduced error pruning."); } else { m_numFolds = Integer.parseInt(numFoldsString); } } else { m_numFolds = 3; } // Other options String minNumString = Utils.getOption('M', options); if (minNumString.length() != 0) { m_minNumObj = Integer.parseInt(minNumString); } else { m_minNumObj = 2; } String seedString = Utils.getOption('Q', options); if (seedString.length() != 0) { m_Seed = Integer.parseInt(seedString); } else { m_Seed = 1; } super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> * -N * Sets if binary attributes are to be coded as nominal ones. * </pre> * * <pre> * -A * For each nominal value a new attribute is created, * not only if there are more than 2 values. * </pre> * * <!-- 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 { setBinaryAttributesNominal(Utils.getFlag('N', options)); setTransformAllValues(Utils.getFlag('A', options)); if (getInputFormat() != null) { setInputFormat(getInputFormat()); } Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * <p>Valid options are: * * <p>-P <start set> <br> * Specify a starting set of attributes. Eg 1,4,7-9. * * <p>-D <0 = forward selection | 1 = floating forward selection> <br> * Forward selection method of the search. (default = 0). * * <p>-N <num> <br> * Number of non improving nodes to consider before terminating search. (default = 5). * * <p>-I <br> * Perform initial ranking to select top-ranked attributes. * * <p>-K <num> <br> * Number of top-ranked attributes that are taken into account. * * <p>-T <0 = fixed-set | 1 = fixed-width> <br> * Typ of Linear Forward Selection (default = 0). * * <p>-S <num> <br> * Size of lookup cache for evaluated subsets. Expressed as a multiple of the number of attributes * in the data set. (default = 1). * * <p>-Z <br> * verbose on/off. * * <p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String optionString; resetOptions(); optionString = Utils.getOption('P', options); if (optionString.length() != 0) { setStartSet(optionString); } optionString = Utils.getOption('D', options); if (optionString.length() != 0) { setForwardSelectionMethod( new SelectedTag(Integer.parseInt(optionString), TAGS_SEARCH_METHOD)); } else { setForwardSelectionMethod(new SelectedTag(SEARCH_METHOD_FORWARD, TAGS_SEARCH_METHOD)); } optionString = Utils.getOption('N', options); if (optionString.length() != 0) { setSearchTermination(Integer.parseInt(optionString)); } setPerformRanking(Utils.getFlag('I', options)); optionString = Utils.getOption('K', options); if (optionString.length() != 0) { setNumUsedAttributes(Integer.parseInt(optionString)); } optionString = Utils.getOption('T', options); if (optionString.length() != 0) { setType(new SelectedTag(Integer.parseInt(optionString), TAGS_TYPE)); } else { setType(new SelectedTag(TYPE_FIXED_SET, TAGS_TYPE)); } optionString = Utils.getOption('S', options); if (optionString.length() != 0) { setLookupCacheSize(Integer.parseInt(optionString)); } m_verbose = Utils.getFlag('Z', options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -N * Initial structure is empty (instead of Naive Bayes)</pre> * * <pre> -P <nr of parents> * Maximum number of parents</pre> * * <pre> -R * Random order. * (default false)</pre> * * <pre> -mbc * Applies a Markov Blanket correction to the network structure, * after a network structure is learned. This ensures that all * nodes in the network are part of the Markov blanket of the * classifier node.</pre> * * <pre> -S [LOO-CV|k-Fold-CV|Cumulative-CV] * Score type (LOO-CV,k-Fold-CV,Cumulative-CV)</pre> * * <pre> -Q * Use probabilistic or 0/1 scoring. * (default probabilistic scoring)</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 { setRandomOrder(Utils.getFlag('R', options)); m_bInitAsNaiveBayes = !(Utils.getFlag('N', options)); String sMaxNrOfParents = Utils.getOption('P', options); if (sMaxNrOfParents.length() != 0) { setMaxNrOfParents(Integer.parseInt(sMaxNrOfParents)); } else { setMaxNrOfParents(100000); } super.setOptions(options); }
/** * Parses a given list of options. Valid options are: * * <p>-folds folds <br> * the number of folds for splitting the training set into train and test set. the first fold is * always the training set. With '-V' you can invert this, i.e., instead of 20/80 for 5 folds * you'll get 80/20. (default 5) * * <p>-V <br> * inverts the fold selection, i.e., instead of using the first fold for the training set it is * used for test set and the remaining folds for training. * * <p>-verbose <br> * whether to output some more information during improving the classifier. * * <p>-insight <br> * whether to use the labels of the original test set to output more statistics. * * <p>Options after -- are passed to the designated classifier. * * <p> * * @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; tmpStr = Utils.getOption("folds", options); if (tmpStr.length() != 0) setSplitFolds(Integer.parseInt(tmpStr)); else setSplitFolds(0); setInvertSplitFolds(Utils.getFlag('V', options)); setVerbose(Utils.getFlag("verbose", options)); setUseInsight(Utils.getFlag("insight", options)); super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -D * Enables debug output. * (default: off)</pre> * * <pre> -F * Stores the filename in an additional attribute. * (default: off)</pre> * * <pre> -dir <directory> * The directory to work on. * (default: current directory)</pre> * * <pre> -charset <charset name> * The character set to use, e.g UTF-8. * (default: use the default character set)</pre> * * <pre> -R * Retain all string attribute values when reading incrementally.</pre> * * <!-- options-end --> * * @param options the options * @throws Exception if options cannot be set */ public void setOptions(String[] options) throws Exception { setDebug(Utils.getFlag("D", options)); setOutputFilename(Utils.getFlag("F", options)); setDirectory(new File(Utils.getOption("dir", options))); String charSet = Utils.getOption("charset", options); m_charSet = ""; if (charSet.length() > 0) { m_charSet = charSet; } setRetainStringValues(Utils.getFlag('R', options)); }
/** * Sets the options. * * @param options the options * @throws Exception if invalid option */ @Override public void setOptions(String[] options) throws Exception { String tmpStr; super.setOptions(options); tmpStr = Utils.getOption('a', options); if (tmpStr.length() != 0) { setNumAttributes(Integer.parseInt(tmpStr)); } else { setNumAttributes(defaultNumAttributes()); } setClassFlag(Utils.getFlag('c', options)); tmpStr = Utils.getOption('b', options); setBooleanIndices(tmpStr); m_booleanCols.setUpper(getNumAttributes() - 1); tmpStr = Utils.getOption('m', options); setNominalIndices(tmpStr); m_nominalCols.setUpper(getNumAttributes() - 1); // check indices tmpStr = checkIndices(); if (tmpStr.length() > 0) { throw new IllegalArgumentException(tmpStr); } }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -M * Minimize expected misclassification cost. Default is to * reweight training instances according to costs per class</pre> * * <pre> -C <cost file name> * File name of a cost matrix to use. If this is not supplied, * a cost matrix will be loaded on demand. The name of the * on-demand file is the relation name of the training data * plus ".cost", and the path to the on-demand file is * specified with the -N option.</pre> * * <pre> -N <directory> * Name of a directory to search for cost files when loading * costs on demand (default current directory).</pre> * * <pre> -cost-matrix <matrix> * The cost matrix in Matlab single line format.</pre> * * <pre> -S <num> * Random number seed. * (default 1)</pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <pre> -W * Full name of base classifier. * (default: weka.classifiers.rules.ZeroR)</pre> * * <pre> * Options specific to classifier weka.classifiers.rules.ZeroR: * </pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <!-- options-end --> * Options after -- are passed to the designated classifier. * * <p> * * @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 { setMinimizeExpectedCost(Utils.getFlag('M', options)); String costFile = Utils.getOption('C', options); if (costFile.length() != 0) { try { setCostMatrix(new CostMatrix(new BufferedReader(new FileReader(costFile)))); } catch (Exception ex) { // now flag as possible old format cost matrix. Delay cost matrix // loading until buildClassifer is called setCostMatrix(null); } setCostMatrixSource(new SelectedTag(MATRIX_SUPPLIED, TAGS_MATRIX_SOURCE)); m_CostFile = costFile; } else { setCostMatrixSource(new SelectedTag(MATRIX_ON_DEMAND, TAGS_MATRIX_SOURCE)); } String demandDir = Utils.getOption('N', options); if (demandDir.length() != 0) { setOnDemandDirectory(new File(demandDir)); } String cost_matrix = Utils.getOption("cost-matrix", options); if (cost_matrix.length() != 0) { StringWriter writer = new StringWriter(); CostMatrix.parseMatlab(cost_matrix).write(writer); setCostMatrix(new CostMatrix(new StringReader(writer.toString()))); setCostMatrixSource(new SelectedTag(MATRIX_SUPPLIED, TAGS_MATRIX_SOURCE)); } super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -B <num> * Manual blend setting (default 20%) * </pre> * * <pre> -E * Enable entropic auto-blend setting (symbolic class only) * </pre> * * <pre> -M <char> * Specify the missing value treatment mode (default a) * Valid options are: a(verage), d(elete), m(axdiff), n(ormal) * </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 { String debug = "(KStar.setOptions)"; String blendStr = Utils.getOption('B', options); if (blendStr.length() != 0) { setGlobalBlend(Integer.parseInt(blendStr)); } setEntropicAutoBlend(Utils.getFlag('E', options)); String missingModeStr = Utils.getOption('M', options); if (missingModeStr.length() != 0) { switch (missingModeStr.charAt(0)) { case 'a': setMissingMode(new SelectedTag(M_AVERAGE, TAGS_MISSING)); break; case 'd': setMissingMode(new SelectedTag(M_DELETE, TAGS_MISSING)); break; case 'm': setMissingMode(new SelectedTag(M_MAXDIFF, TAGS_MISSING)); break; case 'n': setMissingMode(new SelectedTag(M_NORMAL, TAGS_MISSING)); break; default: setMissingMode(new SelectedTag(M_AVERAGE, TAGS_MISSING)); } } Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -C <col> * Index of the attribute to be changed * (default last attribute)</pre> * * <pre> -M * Treat missing values as an extra value * </pre> * * <pre> -P <num> * Specify the percentage of noise introduced * to the data (default 10)</pre> * * <pre> -S <num> * Specify the random number seed (default 1)</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 { String indexString = Utils.getOption('C', options); if (indexString.length() != 0) { setAttributeIndex(indexString); } else { setAttributeIndex("last"); } if (Utils.getFlag('M', options)) { setUseMissing(true); } String percentString = Utils.getOption('P', options); if (percentString.length() != 0) { setPercent((int) Double.valueOf(percentString).doubleValue()); } else { setPercent(10); } String seedString = Utils.getOption('S', options); if (seedString.length() != 0) { setRandomSeed(Integer.parseInt(seedString)); } else { setRandomSeed(1); } }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -P <start set> * Specify a starting set of attributes. * Eg. 1,3,5-7.</pre> * * <pre> -D <0 = backward | 1 = forward | 2 = bi-directional> * Direction of search. (default = 1).</pre> * * <pre> -N <num> * Number of non-improving nodes to * consider before terminating search.</pre> * * <pre> -S <num> * Size of lookup cache for evaluated subsets. * Expressed as a multiple of the number of * attributes in the data set. (default = 1)</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 { String optionString; resetOptions(); optionString = Utils.getOption('P', options); if (optionString.length() != 0) { setStartSet(optionString); } optionString = Utils.getOption('D', options); if (optionString.length() != 0) { setDirection(new SelectedTag(Integer.parseInt(optionString), TAGS_SELECTION)); } else { setDirection(new SelectedTag(SELECTION_FORWARD, TAGS_SELECTION)); } optionString = Utils.getOption('N', options); if (optionString.length() != 0) { setSearchTermination(Integer.parseInt(optionString)); } optionString = Utils.getOption('S', options); if (optionString.length() != 0) { setLookupCacheSize(Integer.parseInt(optionString)); } m_debug = Utils.getFlag('Z', options); }
/** * Parses a given list of options. * <!-- options-start --> * Valid options are: * * <p> * * <pre> -Q <query> * SQL query to execute.</pre> * * <pre> -S * Return sparse rather than normal instances.</pre> * * <pre> -U <username> * The username to use for connecting.</pre> * * <pre> -P <password> * The password to use for connecting.</pre> * * <pre> -D * Enables debug output.</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 { String tmpStr; setSparseData(Utils.getFlag('S', options)); tmpStr = Utils.getOption('Q', options); if (tmpStr.length() != 0) setQuery(tmpStr); tmpStr = Utils.getOption('U', options); if (tmpStr.length() != 0) setUsername(tmpStr); tmpStr = Utils.getOption('P', options); if (tmpStr.length() != 0) setPassword(tmpStr); setDebug(Utils.getFlag('D', options)); }
public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) Filter.batchFilterFile(new Nominal(), argv); else Filter.filterFile(new Nominal(), argv); } catch (Exception ex) { System.out.println(ex.getMessage()); } }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> * -R * Attributes to act on. Can be either a range * string (e.g. 1,2,6-10) OR a comma-separated list of named attributes * (default none) * </pre> * * <pre> * -V * Invert matching sense (i.e. act on all attributes other than those specified) * </pre> * * <pre> * -N * Nominal labels and their replacement values. * E.g. red:blue, black:white, fred:bob * </pre> * * <pre> * -I * Ignore case when matching nominal values * </pre> * * <!-- 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 atts = Utils.getOption('R', options); if (atts.length() > 0) { setSelectedAttributes(atts); } String replacements = Utils.getOption('N', options); if (replacements.length() > 0) { setValueReplacements(replacements); } setInvertSelection(Utils.getFlag('V', options)); setIgnoreCase(Utils.getFlag('I', options)); Utils.checkForRemainingOptions(options); }
/** * Parses a given list of options. * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String optionString = Utils.getOption('A', options); if (optionString.length() != 0) setAlphaStar(Double.parseDouble(optionString)); optionString = Utils.getOption('S', options); if (optionString.length() != 0) setSigma(Double.parseDouble(optionString)); optionString = Utils.getOption('R', options); if (optionString.length() != 0) setR(Double.parseDouble(optionString)); setUseSparseMatrix(Utils.getFlag('M', options)); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -D * Produce debugging output. * (default no debugging output)</pre> * * <pre> -S <number of selection method> * Set the attribute selection method to use. 1 = None, 2 = Greedy. * (default 0 = M5' method)</pre> * * <pre> -C * Do not try to eliminate colinear attributes. * </pre> * * <pre> -R <double> * Set ridge parameter (default 1.0e-8). * </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 { String selectionString = Utils.getOption('S', options); if (selectionString.length() != 0) { setAttributeSelectionMethod( new SelectedTag(Integer.parseInt(selectionString), TAGS_SELECTION)); } else { setAttributeSelectionMethod(new SelectedTag(SELECTION_M5, TAGS_SELECTION)); } String ridgeString = Utils.getOption('R', options); if (ridgeString.length() != 0) { setRidge(new Double(ridgeString).doubleValue()); } else { setRidge(1.0e-8); } setDebug(Utils.getFlag('D', options)); setEliminateColinearAttributes(!Utils.getFlag('C', options)); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -I <num> * Number of iterations. * (default 10)</pre> * * <pre> -R <num> * Number of restarts. * (default 10)</pre> * * <pre> -log * Creates logs in the tmp directory for all kinds of internal data. * Use only for debugging purposes! * </pre> * * <pre> -U * Updates also the labels of the training set. * </pre> * * <pre> -eval <num> * The type of evaluation to use (0 = Randomwalk/Last model used for * prediction, 1=Randomwalk/Best model used for prediction, * 2=Hillclimbing). * </pre> * * <pre> -compare <num> * The type of comparisong used for comparing models. * (0=overall RMS, 1=RMS on train set, 2=RMS on test set, * 3=Accuracy on train set) * </pre> * * <pre> -flipper "<classname [parameters]>" * The flipping algorithm (and optional parameters) to use for * flipping labels. * </pre> * * <pre> -folds <folds> * The number of folds for splitting the training set into * train and test set. The first fold is always the training * set. With '-V' you can invert this, i.e., instead of 20/80 * for 5 folds you'll get 80/20. * (default 5)</pre> * * <pre> -V * Inverts the fold selection, i.e., instead of using the first * fold for the training set it is used for test set and the * remaining folds for training.</pre> * * <pre> -verbose * Whether to print some more information during building the * classifier. * (default is off)</pre> * * <pre> -verbose * Whether to print some more information during building the * classifier. * (default is off)</pre> * * <pre> -S <num> * Random number seed. * (default 1)</pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <pre> -W * Full name of base classifier. * (default: weka.classifiers.trees.J48)</pre> * * <pre> * Options specific to classifier weka.classifiers.trees.J48: * </pre> * * <pre> -U * Use unpruned tree.</pre> * * <pre> -C <pruning confidence> * Set confidence threshold for pruning. * (default 0.25)</pre> * * <pre> -M <minimum number of instances> * Set minimum number of instances per leaf. * (default 2)</pre> * * <pre> -R * Use reduced error pruning.</pre> * * <pre> -N <number of folds> * Set number of folds for reduced error * pruning. One fold is used as pruning set. * (default 3)</pre> * * <pre> -B * Use binary splits only.</pre> * * <pre> -S * Don't perform subtree raising.</pre> * * <pre> -L * Do not clean up after the tree has been built.</pre> * * <pre> -A * Laplace smoothing for predicted probabilities.</pre> * * <pre> -Q <seed> * Seed for random data shuffling (default 1).</pre> * * <!-- options-end --> * Options after -- are passed to the designated classifier. * * <p> * * @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; tmpStr = Utils.getOption('I', options); if (tmpStr.length() != 0) setNumIterations(Integer.parseInt(tmpStr)); else setNumIterations(10); tmpStr = Utils.getOption('R', options); if (tmpStr.length() != 0) setNumRestarts(Integer.parseInt(tmpStr)); else setNumRestarts(10); setLog(Utils.getFlag("log", options)); setUpdateTraining(Utils.getFlag('U', options)); tmpStr = Utils.getOption("eval", options); if (tmpStr.length() != 0) setEvaluationType(new SelectedTag(Integer.parseInt(tmpStr), CollectiveInstances.EVAL_TAGS)); else setEvaluationType( new SelectedTag(CollectiveInstances.EVAL_RANDOMWALK_LAST, CollectiveInstances.EVAL_TAGS)); tmpStr = Utils.getOption("compare", options); if (tmpStr.length() != 0) setComparisonType( new SelectedTag(Integer.parseInt(tmpStr), CollectiveInstances.COMPARE_TAGS)); else setComparisonType( new SelectedTag(CollectiveInstances.COMPARE_RMS, CollectiveInstances.COMPARE_TAGS)); tmpStr = Utils.getOption("flipper", options); if (tmpStr.length() != 0) { tmpOptions = Utils.splitOptions(tmpStr); tmpStr = tmpOptions[0]; tmpOptions[0] = ""; setFlipper(Flipper.forName(tmpStr, tmpOptions)); } else { setFlipper(new TriangleFlipper()); } super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -N <num> * number of clusters. * (default 2).</pre> * * <pre> -P * Initialize using the k-means++ method. * </pre> * * <pre> -V * Display std. deviations for centroids. * </pre> * * <pre> -M * Replace missing values with mean/mode. * </pre> * * <pre> -A <classname and options> * Distance function to use. * (default: weka.core.EuclideanDistance)</pre> * * <pre> -I <num> * Maximum number of iterations. * </pre> * * <pre> -O * Preserve order of instances. * </pre> * * <pre> -fast * Enables faster distance calculations, using cut-off values. * Disables the calculation/output of squared errors/distances. * </pre> * * <pre> -S <num> * Random number seed. * (default 10)</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 { String optionString = Utils.getOption("I", options); if (optionString.length() != 0) { setMaxIterations(Integer.parseInt(optionString)); } optionString = Utils.getOption("max", options); if (optionString.length() > 0) { setMaxNumClusters(Integer.parseInt(optionString)); } optionString = Utils.getOption("min", options); if (optionString.length() > 0) { setMinNumClusters(Integer.parseInt(optionString)); } optionString = Utils.getOption("restarts", options); if (optionString.length() > 0) { setRestarts(Integer.parseInt(optionString)); } setManuallySelectNumClusters(Utils.getFlag("manual", options)); setPrintDebug(Utils.getFlag("debug", options)); initializeWithKMeansPlusPlus = Utils.getFlag('P', options); String distFunctionClass = Utils.getOption('A', options); if (distFunctionClass.length() != 0) { String distFunctionClassSpec[] = Utils.splitOptions(distFunctionClass); if (distFunctionClassSpec.length == 0) { throw new Exception("Invalid DistanceFunction specification string."); } String className = distFunctionClassSpec[0]; distFunctionClassSpec[0] = ""; setDistanceFunction( (DistanceFunction) Utils.forName(DistanceFunction.class, className, distFunctionClassSpec)); } else { setDistanceFunction(new EuclideanDistance()); } super.setOptions(options); }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -D * Enables debugging output (if available) to be printed. * (default: off)</pre> * * <pre> -no-checks * Turns off all checks - use with caution! * (default: checks on)</pre> * * <pre> -C <num> * The size of the cache (a prime number), 0 for full cache and * -1 to turn it off. * (default: 250007)</pre> * * <pre> -E <num> * The Exponent to use. * (default: 1.0)</pre> * * <pre> -L * Use lower-order terms. * (default: no)</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 { String tmpStr; tmpStr = Utils.getOption('E', options); if (tmpStr.length() != 0) setExponent(Double.parseDouble(tmpStr)); else setExponent(1.0); setUseLowerOrder(Utils.getFlag('L', options)); super.setOptions(options); }
/** * Main method for testing this class. * * @param args should contain arguments to the filter: use -h for help */ public static void main(String[] args) { try { if (Utils.getFlag('b', args)) { Filter.batchFilterFile(new AddExpression(), args); } else { Filter.filterFile(new AddExpression(), args); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
/** * Parses the options for this object. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> -S <search method specification> * Full class name of search method, followed * by its options. * eg: "weka.attributeSelection.BestFirst -D 1" * (default weka.attributeSelection.BestFirst)</pre> * * <pre> -X <number of folds> * Use cross validation to evaluate features. * Use number of folds = 1 for leave one out CV. * (Default = leave one out CV)</pre> * * <pre> -E <acc | rmse | mae | auc> * Performance evaluation measure to use for selecting attributes. * (Default = accuracy for discrete class and rmse for numeric class)</pre> * * <pre> -I * Use nearest neighbour instead of global table majority.</pre> * * <pre> -R * Display decision table rules. * </pre> * * <pre> * Options specific to search method weka.attributeSelection.BestFirst: * </pre> * * <pre> -P <start set> * Specify a starting set of attributes. * Eg. 1,3,5-7.</pre> * * <pre> -D <0 = backward | 1 = forward | 2 = bi-directional> * Direction of search. (default = 1).</pre> * * <pre> -N <num> * Number of non-improving nodes to * consider before terminating search.</pre> * * <pre> -S <num> * Size of lookup cache for evaluated subsets. * Expressed as a multiple of the number of * attributes in the data set. (default = 1)</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 { String optionString; resetOptions(); optionString = Utils.getOption('X', options); if (optionString.length() != 0) { m_CVFolds = Integer.parseInt(optionString); } m_useIBk = Utils.getFlag('I', options); m_displayRules = Utils.getFlag('R', options); optionString = Utils.getOption('E', options); if (optionString.length() != 0) { if (optionString.equals("acc")) { setEvaluationMeasure(new SelectedTag(EVAL_ACCURACY, TAGS_EVALUATION)); } else if (optionString.equals("rmse")) { setEvaluationMeasure(new SelectedTag(EVAL_RMSE, TAGS_EVALUATION)); } else if (optionString.equals("mae")) { setEvaluationMeasure(new SelectedTag(EVAL_MAE, TAGS_EVALUATION)); } else if (optionString.equals("auc")) { setEvaluationMeasure(new SelectedTag(EVAL_AUC, TAGS_EVALUATION)); } else { throw new IllegalArgumentException("Invalid evaluation measure"); } } String searchString = Utils.getOption('S', options); if (searchString.length() == 0) searchString = weka.attributeSelection.BestFirst.class.getName(); String[] searchSpec = Utils.splitOptions(searchString); if (searchSpec.length == 0) { throw new IllegalArgumentException("Invalid search specification string"); } String searchName = searchSpec[0]; searchSpec[0] = ""; setSearch(ASSearch.forName(searchName, searchSpec)); }
/** * Parses a given list of options. * <!-- options-start --> * Valid options are: * * <p> * * <pre> -Q <query> * SQL query to execute.</pre> * * <pre> -S * Return sparse rather than normal instances.</pre> * * <pre> -U <username> * The username to use for connecting.</pre> * * <pre> -P <password> * The password to use for connecting.</pre> * * <pre> -D * Enables debug output.</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 { String tmpStr; setSparseData(Utils.getFlag('S', options)); tmpStr = Utils.getOption('Q', options); if (tmpStr.length() != 0) setQuery(tmpStr); tmpStr = Utils.getOption('U', options); if (tmpStr.length() != 0) setUsername(tmpStr); tmpStr = Utils.getOption('P', options); if (tmpStr.length() != 0) setPassword(tmpStr); tmpStr = Utils.getOption("custom-props", options); if (tmpStr.length() == 0) setCustomPropsFile(null); else setCustomPropsFile(new File(tmpStr)); setDebug(Utils.getFlag('D', options)); }
public void setOptions(String[] options) throws Exception { String knnString = Utils.getOption('K', options); if (knnString.length() != 0) { classifier.setkNearest(Integer.parseInt(knnString)); } else { classifier.setkNearest(1); } if (Utils.getFlag('I', options)) { classifier.setInverseWeighting(true); } else { classifier.setInverseWeighting(false); } if (Utils.getFlag('E', options)) { classifier.setMetric(1); } else { classifier.setMetric(0); } }