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

The following examples show how to use weka.core.Utils#getOptionPos() . 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: StrUtils.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isOption(String flag, String[] options) {
    try {
        flag = unflagify(flag);
        int i = Utils.getOptionPos(flag, options);
        if(i < 0 || i + 1 >= options.length) {
            return false;
        }
        String option = options[i + 1];
        if(isFlag(option)) {
            return false;
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 2
Source File: ARAMNetworkfast.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
     activity_report = (Utils.getOptionPos("Rt",options) >= 0) ? Utils.getOption("Rt", options) : "";
     
  super.setOptions(options);
 }
 
Example 3
Source File: ARAMNetworkSparseH.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 4
Source File: ARAMNetwork.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 5
Source File: ARAMNetworkSparse.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 6
Source File: ARAMNetworkSparseV.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 7
Source File: ARAMNetworkSparseHT_Strange.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 8
Source File: ARAMNetworkSparseHT.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 9
Source File: WARAM.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Parses a given list of options. Valid options are:<p>
  *
  * -K <br>
  * Use kernel estimation for modelling numeric attributes rather than
  * a single normal distribution.<p>
  *
  * -D <br>
  * Use supervised discretization to process numeric attributes.
  *
  * @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 {
  //These are just examples, modify to suit your algorithm
//    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);
     roa = (Utils.getOptionPos("P",options) >= 0) ? Double.parseDouble(Utils.getOption("P", options)) : roa;
     m_userankstoclass= (Utils.getOptionPos("K",options) >= 0);
  super.setOptions(options);
 }
 
Example 10
Source File: OptionUtils.java    From meka with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Parses an array option, returns all the occurrences of the option as a string array.
 *
 * @param options       the option array to use
 * @param option        the option to look for in the options array (no leading dash)
 * @return              the parsed value (or default value if option not present)
 * @throws Exception    if parsing of value fails
 */
public static String[] parse(String[] options, String option) throws Exception {
	List<String> result = new ArrayList<>();
	while (Utils.getOptionPos(option, options) > -1)
		result.add(Utils.getOption(option, options));
	return result.toArray(new String[result.size()]);
}