Java Code Examples for weka.core.Utils#checkForRemainingOptions()

The following examples show how to use weka.core.Utils#checkForRemainingOptions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ADTree.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -B num <br>
  * Set the number of boosting iterations
  * (default 10) <p>
  *
  * -E num <br>
  * Set the nodes to expand: -3(all), -2(weight), -1(z_pure), >=0 seed for random walk
  * (default -3) <p>
  *
  * -D <br>
  * Save the instance data with the model <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 bString = Utils.getOption('B', options);
   if (bString.length() != 0) setNumOfBoostingIterations(Integer.parseInt(bString));

   String eString = Utils.getOption('E', options);
   if (eString.length() != 0) {
     int value = Integer.parseInt(eString);
     if (value >= 0) {
setSearchPath(new SelectedTag(SEARCHPATH_RANDOM, TAGS_SEARCHPATH));
setRandomSeed(value);
     } else setSearchPath(new SelectedTag(value + 3, TAGS_SEARCHPATH));
   }

   setSaveInstanceData(Utils.getFlag('D', options));

   Utils.checkForRemainingOptions(options);
 }
 
Example 2
Source File: FPGrowth.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Main method.
 * 
 * @param args the commandline options
 */
public static void main(String[] args) {
  try {
    String[] argsCopy = args.clone();
    if (Utils.getFlag('h', argsCopy) || Utils.getFlag("help", argsCopy)) {
      runAssociator(new FPGrowth(), args);
      System.out.println("-disk\n\tProcess data off of disk instead of loading\n\t" +
      		"into main memory. This is a command line only option.");
      return;
    }
      
    if (!Utils.getFlag("disk", args)) {
      runAssociator(new FPGrowth(), args);
    } else {
      String filename;
      filename = Utils.getOption('t', args);
      weka.core.converters.ArffLoader loader = null;
      if (filename.length() != 0) {
        loader = new weka.core.converters.ArffLoader();
        loader.setFile(new java.io.File(filename));
      } else {
        throw new Exception("No training file specified!");
      }
      FPGrowth fpGrowth = new FPGrowth();
      fpGrowth.setOptions(args);
      Utils.checkForRemainingOptions(args);
      fpGrowth.buildAssociations(loader);
      System.out.print(fpGrowth.toString());
    }
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
Example 3
Source File: BayesNet.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Parses a given list of options. <p>
 * 
   <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -D
 *  Do not use ADTree data structure
 * </pre>
 * 
 * <pre> -B &lt;BIF file&gt;
 *  BIF file to compare with
 * </pre>
 * 
 * <pre> -Q weka.classifiers.bayes.net.search.SearchAlgorithm
 *  Search algorithm
 * </pre>
 * 
 * <pre> -E weka.classifiers.bayes.net.estimate.SimpleEstimator
 *  Estimator algorithm
 * </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 {
  m_bUseADTree = !(Utils.getFlag('D', options));

  String sBIFFile = Utils.getOption('B', options);
  if (sBIFFile != null && !sBIFFile.equals("")) {
    setBIFFile(sBIFFile);
  }

  String searchAlgorithmName = Utils.getOption('Q', options);
  if (searchAlgorithmName.length() != 0) {
    setSearchAlgorithm(
 (SearchAlgorithm) Utils.forName(
     SearchAlgorithm.class,
     searchAlgorithmName,
     partitionOptions(options)));
  }
  else {
    setSearchAlgorithm(new K2());
  }


  String estimatorName = Utils.getOption('E', options);
  if (estimatorName.length() != 0) {
    setEstimator(
 (BayesNetEstimator) Utils.forName(
     BayesNetEstimator.class,
     estimatorName,
     Utils.partitionOptions(options)));
  }
  else {
    setEstimator(new SimpleEstimator());
  }

  Utils.checkForRemainingOptions(options);
}
 
Example 4
Source File: RBFNetwork.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -B &lt;number&gt;
 *  Set the number of clusters (basis functions) to generate. (default = 2).</pre>
 * 
 * <pre> -S &lt;seed&gt;
 *  Set the random seed to be used by K-means. (default = 1).</pre>
 * 
 * <pre> -R &lt;ridge&gt;
 *  Set the ridge value for the logistic or linear regression.</pre>
 * 
 * <pre> -M &lt;number&gt;
 *  Set the maximum number of iterations for the logistic regression. (default -1, until convergence).</pre>
 * 
 * <pre> -W &lt;number&gt;
 *  Set the minimum standard deviation for the clusters. (default 0.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 {
  setDebug(Utils.getFlag('D', options));

  String ridgeString = Utils.getOption('R', options);
  if (ridgeString.length() != 0) {
    m_ridge = Double.parseDouble(ridgeString);
  } else {
    m_ridge = 1.0e-8;
  }
	
  String maxItsString = Utils.getOption('M', options);
  if (maxItsString.length() != 0) {
    m_maxIts = Integer.parseInt(maxItsString);
  } else {
    m_maxIts = -1;
  }

  String numClustersString = Utils.getOption('B', options);
  if (numClustersString.length() != 0) {
    setNumClusters(Integer.parseInt(numClustersString));
  }

  String seedString = Utils.getOption('S', options);
  if (seedString.length() != 0) {
    setClusteringSeed(Integer.parseInt(seedString));
  }
  String stdString = Utils.getOption('W', options);
  if (stdString.length() != 0) {
    setMinStdDev(Double.parseDouble(stdString));
  }
  Utils.checkForRemainingOptions(options);
}
 
Example 5
Source File: KStar.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * 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);
 }
 
Example 6
Source File: RemoveMisclassified.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 * 
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -W &lt;classifier specification&gt;
 *  Full class name of classifier to use, followed
 *  by scheme options. eg:
 *   "weka.classifiers.bayes.NaiveBayes -D"
 *  (default: weka.classifiers.rules.ZeroR)</pre>
 * 
 * <pre> -C &lt;class index&gt;
 *  Attribute on which misclassifications are based.
 *  If &lt; 0 will use any current set class or default to the last attribute.</pre>
 * 
 * <pre> -F &lt;number of folds&gt;
 *  The number of folds to use for cross-validation cleansing.
 *  (&lt;2 = no cross-validation - default).</pre>
 * 
 * <pre> -T &lt;threshold&gt;
 *  Threshold for the max error when predicting numeric class.
 *  (Value should be &gt;= 0, default = 0.1).</pre>
 * 
 * <pre> -I
 *  The maximum number of cleansing iterations to perform.
 *  (&lt;1 = until fully cleansed - default)</pre>
 * 
 * <pre> -V
 *  Invert the match so that correctly classified instances are discarded.
 * </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 classifierString = Utils.getOption('W', options);
  if (classifierString.length() == 0)
    classifierString = weka.classifiers.rules.ZeroR.class.getName();
  String[] classifierSpec = Utils.splitOptions(classifierString);
  if (classifierSpec.length == 0) {
    throw new Exception("Invalid classifier specification string");
  }
  String classifierName = classifierSpec[0];
  classifierSpec[0] = "";
  setClassifier(AbstractClassifier.forName(classifierName, classifierSpec));

  String cString = Utils.getOption('C', options);
  if (cString.length() != 0) {
    setClassIndex((new Double(cString)).intValue());
  } else {
    setClassIndex(-1);
  }

  String fString = Utils.getOption('F', options);
  if (fString.length() != 0) {
    setNumFolds((new Double(fString)).intValue());
  } else {
    setNumFolds(0);
  }

  String tString = Utils.getOption('T', options);
  if (tString.length() != 0) {
    setThreshold((new Double(tString)).doubleValue());
  } else {
    setThreshold(0.1);
  }

  String iString = Utils.getOption('I', options);
  if (iString.length() != 0) {
    setMaxIterations((new Double(iString)).intValue());
  } else {
    setMaxIterations(0);
  }
  
  if (Utils.getFlag('V', options)) {
    setInvert(true);
  } else {
    setInvert(false);
  }
      
  Utils.checkForRemainingOptions(options);

}
 
Example 7
Source File: HierarchicalClusterer.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
  <!-- options-start -->
 * Valid options are: <p/>
 * 
  <!-- 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 {
  m_bPrintNewick = Utils.getFlag('P', options);

  String optionString = Utils.getOption('N', options); 
  if (optionString.length() != 0) {
    Integer temp = new Integer(optionString);
    setNumClusters(temp);
  }
  else {
    setNumClusters(2);
  }

  setDebug(Utils.getFlag('D', options));
  setDistanceIsBranchLength(Utils.getFlag('B', options));

  String sLinkType = Utils.getOption('L', options);


  if (sLinkType.compareTo("SINGLE") == 0) {setLinkType(new SelectedTag(SINGLE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("COMPLETE") == 0) {setLinkType(new SelectedTag(COMPLETE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("AVERAGE") == 0) {setLinkType(new SelectedTag(AVERAGE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("MEAN") == 0) {setLinkType(new SelectedTag(MEAN, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("CENTROID") == 0) {setLinkType(new SelectedTag(CENTROID, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("WARD") == 0) {setLinkType(new SelectedTag(WARD, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("ADJCOMLPETE") == 0) {setLinkType(new SelectedTag(ADJCOMLPETE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("NEIGHBOR_JOINING") == 0) {setLinkType(new SelectedTag(NEIGHBOR_JOINING, TAGS_LINK_TYPE));}

  String nnSearchClass = Utils.getOption('A', options);
  if(nnSearchClass.length() != 0) {
    String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
    if(nnSearchClassSpec.length == 0) { 
      throw new Exception("Invalid DistanceFunction specification string."); 
    }
    String className = nnSearchClassSpec[0];
    nnSearchClassSpec[0] = "";

    setDistanceFunction( (DistanceFunction)
        Utils.forName( DistanceFunction.class, 
            className, nnSearchClassSpec) );
  }
  else {
    setDistanceFunction(new EuclideanDistance());
  }

  Utils.checkForRemainingOptions(options);
}
 
Example 8
Source File: REPTree.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 * 
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -M &lt;minimum number of instances&gt;
 *  Set minimum number of instances per leaf (default 2).</pre>
 * 
 * <pre> -V &lt;minimum variance for split&gt;
 *  Set minimum numeric class variance proportion
 *  of train variance for split (default 1e-3).</pre>
 * 
 * <pre> -N &lt;number of folds&gt;
 *  Number of folds for reduced error pruning (default 3).</pre>
 * 
 * <pre> -S &lt;seed&gt;
 *  Seed for random data shuffling (default 1).</pre>
 * 
 * <pre> -P
 *  No pruning.</pre>
 * 
 * <pre> -L
 *  Maximum tree depth (default -1, no maximum)</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 minNumString = Utils.getOption('M', options);
  if (minNumString.length() != 0) {
    m_MinNum = (double)Integer.parseInt(minNumString);
  } else {
    m_MinNum = 2;
  }
  String minVarString = Utils.getOption('V', options);
  if (minVarString.length() != 0) {
    m_MinVarianceProp = Double.parseDouble(minVarString);
  } else {
    m_MinVarianceProp = 1e-3;
  }
  String numFoldsString = Utils.getOption('N', options);
  if (numFoldsString.length() != 0) {
    m_NumFolds = Integer.parseInt(numFoldsString);
  } else {
    m_NumFolds = 3;
  }
  String seedString = Utils.getOption('S', options);
  if (seedString.length() != 0) {
    m_Seed = Integer.parseInt(seedString);
  } else {
    m_Seed = 1;
  }
  m_NoPruning = Utils.getFlag('P', options);
  String depthString = Utils.getOption('L', options);
  if (depthString.length() != 0) {
    m_MaxDepth = Integer.parseInt(depthString);
  } else {
    m_MaxDepth = -1;
  }
  String initialCountString = Utils.getOption('I', options);
  if (initialCountString.length() != 0) {
    m_InitialCount = Double.parseDouble(initialCountString);
  } else {
    m_InitialCount = 0;
  }
  m_SpreadInitialCount = Utils.getFlag('R', options);
  
  Utils.checkForRemainingOptions(options);
}
 
Example 9
Source File: OneRAttributeEval.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -S &lt;seed&gt;
 *  Random number seed for cross validation
 *  (default = 1)</pre>
 * 
 * <pre> -F &lt;folds&gt;
 *  Number of folds for cross validation
 *  (default = 10)</pre>
 * 
 * <pre> -D
 *  Use training data for evaluation rather than cross validaton</pre>
 * 
 * <pre> -B &lt;minimum bucket size&gt;
 *  Minimum number of objects in a bucket
 *  (passed on to OneR, default = 6)</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 temp = Utils.getOption('S', options);

  if (temp.length() != 0) {
    setSeed(Integer.parseInt(temp));
  }
  
  temp = Utils.getOption('F', options);
  if (temp.length() != 0) {
    setFolds(Integer.parseInt(temp));
  }

  temp = Utils.getOption('B', options);
  if (temp.length() != 0) {
    setMinimumBucketSize(Integer.parseInt(temp));
  }
  
  setEvalUsingTrainingData(Utils.getFlag('D', options));
  Utils.checkForRemainingOptions(options);
}
 
Example 10
Source File: SimpleCart.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 * 
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <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> -M &lt;min no&gt;
 *  The minimal number of instances at the terminal nodes.
 *  (default 2)</pre>
 * 
 * <pre> -N &lt;num folds&gt;
 *  The number of folds used in the minimal cost-complexity pruning.
 *  (default 5)</pre>
 * 
 * <pre> -U
 *  Don't use the minimal cost-complexity pruning.
 *  (default yes).</pre>
 * 
 * <pre> -H
 *  Don't use the heuristic method for binary split.
 *  (default true).</pre>
 * 
 * <pre> -A
 *  Use 1 SE rule to make pruning decision.
 *  (default no).</pre>
 * 
 * <pre> -C
 *  Percentage of training data size (0-1].
 *  (default 1).</pre>
 * 
 <!-- options-end -->
 * 
 * @param options the list of options as an array of strings
 * @throws Exception if an options is not supported
 */
public void setOptions(String[] options) throws Exception {
  String	tmpStr;
  
  super.setOptions(options);
  
  tmpStr = Utils.getOption('M', options);
  if (tmpStr.length() != 0)
    setMinNumObj(Double.parseDouble(tmpStr));
  else
    setMinNumObj(2);

  tmpStr = Utils.getOption('N', options);
  if (tmpStr.length()!=0)
    setNumFoldsPruning(Integer.parseInt(tmpStr));
  else
    setNumFoldsPruning(5);

  setUsePrune(!Utils.getFlag('U',options));
  setHeuristic(!Utils.getFlag('H',options));
  setUseOneSE(Utils.getFlag('A',options));

  tmpStr = Utils.getOption('C', options);
  if (tmpStr.length()!=0)
    setSizePer(Double.parseDouble(tmpStr));
  else
    setSizePer(1);

  Utils.checkForRemainingOptions(options);
}
 
Example 11
Source File: PartitionMembership.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 * 
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -W &lt;name of partition generator&gt;
 *  Full name of partition generator to use, e.g.:
 *   weka.classifiers.trees.J48
 *  Additional options after the '--'.
 *  (default: weka.classifiers.trees.J48)</pre>
 * 
 <!-- options-end -->
 *
 * Options after the -- are passed on to the clusterer.
 *
 * @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 generatorString = Utils.getOption('W', options);
  if (generatorString.length() == 0) {
    generatorString = J48.class.getName();
  }
  setPartitionGenerator((PartitionGenerator)Utils.
                        forName(PartitionGenerator.class, generatorString,
                                Utils.partitionOptions(options)));
  
  Utils.checkForRemainingOptions(options);
}
 
Example 12
Source File: FT.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 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);
	
}
 
Example 13
Source File: SimpleLogistic.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
    * Parses a given list of options. <p/>
    *
    <!-- options-start -->
    * Valid options are: <p/>
    * 
    * <pre> -I &lt;iterations&gt;
    *  Set fixed number of iterations for LogitBoost</pre>
    * 
    * <pre> -S
    *  Use stopping criterion on training set (instead of
    *  cross-validation)</pre>
    * 
    * <pre> -P
    *  Use error on probabilities (rmse) instead of
    *  misclassification error for stopping criterion</pre>
    * 
    * <pre> -M &lt;iterations&gt;
    *  Set maximum number of boosting iterations</pre>
    * 
    * <pre> -H &lt;iterations&gt;
    *  Set parameter for heuristic for early stopping of
    *  LogitBoost.
    *  If enabled, the minimum is selected greedily, stopping
    *  if the current minimum has not changed for iter iterations.
    *  By default, heuristic is enabled with value 50. Set to
    *  zero to disable heuristic.</pre>
    * 
    * <pre> -W &lt;beta&gt;
    *  Set beta for weight trimming for LogitBoost. Set to 0 for no weight trimming.
    * </pre>
    * 
    * <pre> -A
    *  The AIC is used to choose the best iteration (instead of CV or training error).
    * </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) {
    setNumBoostingIterations((new Integer(optionString)).intValue());
}
	
setUseCrossValidation(!Utils.getFlag('S', options));
setErrorOnProbabilities(Utils.getFlag('P', options));

optionString = Utils.getOption('M', options);
if (optionString.length() != 0) {
    setMaxBoostingIterations((new Integer(optionString)).intValue());
}

optionString = Utils.getOption('H', options);
if (optionString.length() != 0) {
    setHeuristicStop((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);
   }
 
Example 14
Source File: NaiveBayes.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -K
 *  Use kernel density estimator rather than normal
 *  distribution for numeric attributes</pre>
 * 
 * <pre> -D
 *  Use supervised discretization to process numeric attributes
 * </pre>
 *
 * <pre> -O
 *  Display model in old format (good when there are many classes)
 * </pre>
 * 
 <!-- options-end -->
 *
 * @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 {

  boolean k = Utils.getFlag('K', options);
  boolean d = Utils.getFlag('D', options);
  if (k && d) {
    throw new IllegalArgumentException("Can't use both kernel density " +
                                       "estimation and discretization!");
  }
  setUseSupervisedDiscretization(d);
  setUseKernelEstimator(k);
  setDisplayModelInOldFormat(Utils.getFlag('O', options));
  Utils.checkForRemainingOptions(options);
}
 
Example 15
Source File: AODEsr.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -D
 *  Output debugging information
 * </pre>
 * 
 * <pre> -C
 *  Impose a critcal value for specialization-generalization relationship
 *  (default is 50)</pre>
 * 
 * <pre> -F
 *  Impose a frequency limit for superParents
 *  (default is 1)</pre>
 * 
 * <pre> -L
 *  Using Laplace estimation
 *  (default is m-esimation (m=1))</pre>
 * 
 * <pre> -M
 *  Weight value for m-estimation
 *  (default is 1.0)</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 {

  m_Debug = Utils.getFlag('D', options);

  String Critical = Utils.getOption('C', options);
  if(Critical.length() != 0) 
     m_Critical = Integer.parseInt(Critical);
  else
     m_Critical = 50;
  
  String Freq = Utils.getOption('F', options);
  if(Freq.length() != 0) 
     m_Limit = Integer.parseInt(Freq);
  else
     m_Limit = 1;
  
  m_Laplace = Utils.getFlag('L', options);
  String MWeight = Utils.getOption('M', options); 
  if(MWeight.length() != 0) {
     if(m_Laplace)
        throw new Exception("weight for m-estimate is pointless if using laplace estimation!");
     m_MWeight = Double.parseDouble(MWeight);
  } else
     m_MWeight = 1.0;
  
  Utils.checkForRemainingOptions(options);
}
 
Example 16
Source File: AddUserFields.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options.
 * <p/>
 * 
 * <!-- options-start --> 
 Valid options are:
 * <p/>
 * 
 * <pre>
 * -A &lt;name:type:value&gt;
 *  New field specification (name&#64;type&#64;value).
 *   Environment variables may be used for any/all parts of the
 *  specification. Type can be one of (numeric, nominal, string or date).
 *  The value for date be a specific date string or the special string
 *  "now" to indicate the current date-time. A specific date format
 *  string for parsing specific date values can be specified by suffixing
 *  the type specification - e.g. "myTime&#64;date:MM-dd-yyyy&#64;08-23-2009".
 *  This option may be specified multiple times
 * </pre>
 * 
 * <!-- options-end -->
 * 
 * @param otions the list of options as an array of string
 * @throws Exception if an option is not supported
 */
@Override
public void setOptions(String[] options) throws Exception {
  clearAttributeSpecs();

  String attS = "";
  while ((attS = Utils.getOption('A', options)).length() > 0) {
    addAttributeSpec(attS);
  }

  Utils.checkForRemainingOptions(options);
}
 
Example 17
Source File: BayesNetEstimator.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -A &lt;alpha&gt;
 *  Initial count (alpha)
 * </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 sAlpha = Utils.getOption('A', options);

    if (sAlpha.length() != 0) {
        m_fAlpha = (new Float(sAlpha)).floatValue();
    } else {
        m_fAlpha = 0.5f;
    }

    Utils.checkForRemainingOptions(options);
}
 
Example 18
Source File: VFI.java    From tsml with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -C
 *  Don't weight voting intervals by confidence</pre>
 * 
 * <pre> -B &lt;bias&gt;
 *  Set exponential bias towards confident intervals
 *  (default = 1.0)</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;
  
  setWeightByConfidence(!Utils.getFlag('C', options));
  
  optionString = Utils.getOption('B', options);
  if (optionString.length() != 0) {
    Double temp = new Double(optionString);
    setBias(temp.doubleValue());
  }

  Utils.checkForRemainingOptions(options);
}
 
Example 19
Source File: RandomTree.java    From tsml with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Parses a given list of options.
 * <p/>
 * 
 <!-- options-start --> 
 * Valid options are:
 * <p/>
 * 
 * <pre>
 * -K &lt;number of attributes&gt;
 *  Number of attributes to randomly investigate
 *  (&lt;0 = int(log_2(#attributes)+1)).
 * </pre>
 * 
 * <pre>
 * -M &lt;minimum number of instances&gt;
 *  Set minimum number of instances per leaf.
 * </pre>
 * 
 * <pre>
 * -S &lt;num&gt;
 *  Seed for random number generator.
 *  (default 1)
 * </pre>
 * 
 * <pre>
 * -depth &lt;num&gt;
 *  The maximum depth of the tree, 0 for unlimited.
 *  (default 0)
 * </pre>
 * 
 * <pre>
 * -N &lt;num&gt;
 *  Number of folds for backfitting (default 0, no backfitting).
 * </pre>
 * 
 * <pre>
 * -U
 *  Allow unclassified instances.
 * </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
 */
@Override
public void setOptions(String[] options) throws Exception {
  String tmpStr;

  tmpStr = Utils.getOption('K', options);
  if (tmpStr.length() != 0) {
    m_KValue = Integer.parseInt(tmpStr);
  } else {
    m_KValue = 0;
  }

  tmpStr = Utils.getOption('M', options);
  if (tmpStr.length() != 0) {
    m_MinNum = Double.parseDouble(tmpStr);
  } else {
    m_MinNum = 1;
  }

  tmpStr = Utils.getOption('S', options);
  if (tmpStr.length() != 0) {
    setSeed(Integer.parseInt(tmpStr));
  } else {
    setSeed(1);
  }

  tmpStr = Utils.getOption("depth", options);
  if (tmpStr.length() != 0) {
    setMaxDepth(Integer.parseInt(tmpStr));
  } else {
    setMaxDepth(0);
  }
  String numFoldsString = Utils.getOption('N', options);
  if (numFoldsString.length() != 0) {
    m_NumFolds = Integer.parseInt(numFoldsString);
  } else {
    m_NumFolds = 0;
  }

  setAllowUnclassifiedInstances(Utils.getFlag('U', options));

  super.setOptions(options);

  Utils.checkForRemainingOptions(options);
}
 
Example 20
Source File: SVMAttributeEval.java    From tsml with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->
 * Valid options are: <p/>
 * 
 * <pre> -X &lt;constant rate of elimination&gt;
 *  Specify the constant rate of attribute
 *  elimination per invocation of
 *  the support vector machine.
 *  Default = 1.</pre>
 * 
 * <pre> -Y &lt;percent rate of elimination&gt;
 *  Specify the percentage rate of attributes to
 *  elimination per invocation of
 *  the support vector machine.
 *  Trumps constant rate (above threshold).
 *  Default = 0.</pre>
 * 
 * <pre> -Z &lt;threshold for percent elimination&gt;
 *  Specify the threshold below which 
 *  percentage attribute elimination
 *  reverts to the constant method.</pre>
 * 
 * <pre> -P &lt;epsilon&gt;
 *  Specify the value of P (epsilon
 *  parameter) to pass on to the
 *  support vector machine.
 *  Default = 1.0e-25</pre>
 * 
 * <pre> -T &lt;tolerance&gt;
 *  Specify the value of T (tolerance
 *  parameter) to pass on to the
 *  support vector machine.
 *  Default = 1.0e-10</pre>
 * 
 * <pre> -C &lt;complexity&gt;
 *  Specify the value of C (complexity
 *  parameter) to pass on to the
 *  support vector machine.
 *  Default = 1.0</pre>
 * 
 * <pre> -N
 *  Whether the SVM should 0=normalize/1=standardize/2=neither.
 *  (default 0=normalize)</pre>
 * 
 <!-- options-end -->
 *
 * @param options the list of options as an array of strings
 * @throws Exception if an error occurs
 */
public void setOptions(String[] options) throws Exception {
  String optionString;

  optionString = Utils.getOption('X', options);
  if (optionString.length() != 0) {
    setAttsToEliminatePerIteration(Integer.parseInt(optionString));
  }

  optionString = Utils.getOption('Y', options);
  if (optionString.length() != 0) {
    setPercentToEliminatePerIteration(Integer.parseInt(optionString));
  }

  optionString = Utils.getOption('Z', options);
  if (optionString.length() != 0) {
    setPercentThreshold(Integer.parseInt(optionString));
  }

  optionString = Utils.getOption('P', options);
  if (optionString.length() != 0) {
    setEpsilonParameter((new Double(optionString)).doubleValue());
  }

  optionString = Utils.getOption('T', options);
  if (optionString.length() != 0) {
    setToleranceParameter((new Double(optionString)).doubleValue());
  }

  optionString = Utils.getOption('C', options);
  if (optionString.length() != 0) {
    setComplexityParameter((new Double(optionString)).doubleValue());
  }

  optionString = Utils.getOption('N', options);
  if (optionString.length() != 0) {
    setFilterType(new SelectedTag(Integer.parseInt(optionString), SMO.TAGS_FILTER));
  } else {
    setFilterType(new SelectedTag(SMO.FILTER_NORMALIZE, SMO.TAGS_FILTER));
  }

  Utils.checkForRemainingOptions(options);
}