/**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -folds &lt;folds&gt;
   *  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 &lt;num&gt;
   *  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 &gt; 1)</pre>
   *
   * <pre> -F
   *  Weight neighbours by 1 - their distance
   *  (use when k &gt; 1)</pre>
   *
   * <pre> -K &lt;number of neighbors&gt;
   *  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!
  }
Пример #2
0
  /**
   * 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));
  }
Пример #3
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -find &lt;regexp&gt;
   *  The regular expression that the attribute names must match.
   *  (default: ([\s\S]+))</pre>
   *
   * <pre> -replace &lt;string&gt;
   *  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 &lt;string&gt;'.
   *  (default: off)</pre>
   *
   * <pre> -all
   *  Replaces all occurrences instead of just the first.
   *  (default: only first occurrence)</pre>
   *
   * <pre> -R &lt;range&gt;
   *  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);
  }
Пример #5
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -R &lt;col1,col2-col4,...&gt;
   *  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 &lt;integer&gt;
   *  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);
  }
Пример #6
0
  /**
   * 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 &lt;numIterations&gt;
   *  Set fixed number of iterations for LogitBoost (instead of using cross-validation)</pre>
   *
   * <pre> -F &lt;modelType&gt;
   *  Set Funtional Tree type to be generate:  0 for FT, 1 for FTLeaves and 2 for FTInner</pre>
   *
   * <pre> -M &lt;numInstances&gt;
   *  Set minimum number of instances at which a node can be split (default 15)</pre>
   *
   * <pre> -W &lt;beta&gt;
   *  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);
  }
Пример #7
0
  /**
   * 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 &lt;numOfRuns&gt;
   *  Set the number of multiple runs
   *  needed for searching the MLE.</pre>
   *
   * <pre> -S &lt;num&gt;
   *  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);
  }
Пример #8
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre>
   * -C &lt;pruning confidence&gt;
   *  Set confidence threshold for pruning.
   *  (default 0.25)
   * </pre>
   *
   * <pre>
   * -M &lt;minimum number of objects&gt;
   *  Set minimum number of objects per leaf.
   *  (default 2)
   * </pre>
   *
   * <pre>
   * -R
   *  Use reduced error pruning.
   * </pre>
   *
   * <pre>
   * -N &lt;number of folds&gt;
   *  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 &lt;seed&gt;
   *  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);
  }
Пример #9
0
  /**
   * 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);
  }
Пример #10
0
  /**
   * 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);
  }
Пример #11
0
  /**
   * 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 &lt;nr of parents&gt;
   *  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);
  }
Пример #13
0
  /**
   * 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 &lt;directory&gt;
   *  The directory to work on.
   *  (default: current directory)</pre>
   *
   * <pre> -charset &lt;charset name&gt;
   *  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));
  }
Пример #14
0
  /**
   * 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);
    }
  }
Пример #15
0
  /**
   * 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 &lt;cost file name&gt;
   *  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 &lt;directory&gt;
   *  Name of a directory to search for cost files when loading
   *  costs on demand (default current directory).</pre>
   *
   * <pre> -cost-matrix &lt;matrix&gt;
   *  The cost matrix in Matlab single line format.</pre>
   *
   * <pre> -S &lt;num&gt;
   *  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);
  }
Пример #16
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -B &lt;num&gt;
   *  Manual blend setting (default 20%)
   * </pre>
   *
   * <pre> -E
   *  Enable entropic auto-blend setting (symbolic class only)
   * </pre>
   *
   * <pre> -M &lt;char&gt;
   *  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);
  }
Пример #17
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -C &lt;col&gt;
   *  Index of the attribute to be changed
   *  (default last attribute)</pre>
   *
   * <pre> -M
   *  Treat missing values as an extra value
   * </pre>
   *
   * <pre> -P &lt;num&gt;
   *  Specify the percentage of noise introduced
   *  to the data (default 10)</pre>
   *
   * <pre> -S &lt;num&gt;
   *  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);
    }
  }
Пример #18
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -P &lt;start set&gt;
   *  Specify a starting set of attributes.
   *  Eg. 1,3,5-7.</pre>
   *
   * <pre> -D &lt;0 = backward | 1 = forward | 2 = bi-directional&gt;
   *  Direction of search. (default = 1).</pre>
   *
   * <pre> -N &lt;num&gt;
   *  Number of non-improving nodes to
   *  consider before terminating search.</pre>
   *
   * <pre> -S &lt;num&gt;
   *  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);
  }
Пример #19
0
  /**
   * Parses a given list of options.
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -Q &lt;query&gt;
   *  SQL query to execute.</pre>
   *
   * <pre> -S
   *  Return sparse rather than normal instances.</pre>
   *
   * <pre> -U &lt;username&gt;
   *  The username to use for connecting.</pre>
   *
   * <pre> -P &lt;password&gt;
   *  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));
  }
Пример #20
0
 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());
   }
 }
Пример #21
0
  /**
   * 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));
 }
Пример #23
0
  /**
   * 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 &lt;number of selection method&gt;
   *  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 &lt;double&gt;
   *  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 &lt;num&gt;
   *  Number of iterations.
   *  (default 10)</pre>
   *
   * <pre> -R &lt;num&gt;
   *  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 &lt;num&gt;
   *  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 &lt;num&gt;
   *  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 "&lt;classname [parameters]&gt;"
   *  The flipping algorithm (and optional parameters) to use for
   *  flipping labels.
   * </pre>
   *
   * <pre> -folds &lt;folds&gt;
   *  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 &lt;num&gt;
   *  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 &lt;pruning confidence&gt;
   *  Set confidence threshold for pruning.
   *  (default 0.25)</pre>
   *
   * <pre> -M &lt;minimum number of instances&gt;
   *  Set minimum number of instances per leaf.
   *  (default 2)</pre>
   *
   * <pre> -R
   *  Use reduced error pruning.</pre>
   *
   * <pre> -N &lt;number of folds&gt;
   *  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 &lt;seed&gt;
   *  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);
  }
Пример #25
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -N &lt;num&gt;
   *  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 &lt;classname and options&gt;
   *  Distance function to use.
   *  (default: weka.core.EuclideanDistance)</pre>
   *
   * <pre> -I &lt;num&gt;
   *  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 &lt;num&gt;
   *  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 &lt;num&gt;
   *  The size of the cache (a prime number), 0 for full cache and
   *  -1 to turn it off.
   *  (default: 250007)</pre>
   *
   * <pre> -E &lt;num&gt;
   *  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);
  }
Пример #27
0
 /**
  * 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());
   }
 }
Пример #28
0
  /**
   * Parses the options for this object.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -S &lt;search method specification&gt;
   *  Full class name of search method, followed
   *  by its options.
   *  eg: "weka.attributeSelection.BestFirst -D 1"
   *  (default weka.attributeSelection.BestFirst)</pre>
   *
   * <pre> -X &lt;number of folds&gt;
   *  Use cross validation to evaluate features.
   *  Use number of folds = 1 for leave one out CV.
   *  (Default = leave one out CV)</pre>
   *
   * <pre> -E &lt;acc | rmse | mae | auc&gt;
   *  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 &lt;start set&gt;
   *  Specify a starting set of attributes.
   *  Eg. 1,3,5-7.</pre>
   *
   * <pre> -D &lt;0 = backward | 1 = forward | 2 = bi-directional&gt;
   *  Direction of search. (default = 1).</pre>
   *
   * <pre> -N &lt;num&gt;
   *  Number of non-improving nodes to
   *  consider before terminating search.</pre>
   *
   * <pre> -S &lt;num&gt;
   *  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));
  }
Пример #29
0
  /**
   * Parses a given list of options.
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -Q &lt;query&gt;
   *  SQL query to execute.</pre>
   *
   * <pre> -S
   *  Return sparse rather than normal instances.</pre>
   *
   * <pre> -U &lt;username&gt;
   *  The username to use for connecting.</pre>
   *
   * <pre> -P &lt;password&gt;
   *  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));
  }
Пример #30
0
  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);
    }
  }