⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tertius.java

📁 Java 编写的多种数据挖掘算法 包括聚类、分类、预处理等
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   <!-- 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 {        resetOptions();        /* Pruning options. */    String bestString = Utils.getOption('K', options);    if (bestString.length() != 0) {      try {	m_best = Integer.parseInt(bestString);      } catch (Exception e) {	throw new Exception("Invalid value for -K option: "			    + e.getMessage() + ".");      }      if (m_best < 1) {	throw new Exception("Number of confirmation values has to be "			    + "greater than one!");      }    }    String frequencyThresholdString = Utils.getOption('F', options);    if (frequencyThresholdString.length() != 0) {      try {		m_frequencyThreshold 	  = (new Double(frequencyThresholdString)).doubleValue();      } catch (Exception e) {	throw new Exception("Invalid value for -F option: "			    + e.getMessage() + ".");      }      if (m_frequencyThreshold < 0 || m_frequencyThreshold > 1) {	throw new Exception("Frequency threshold has to be between "			    + "zero and one!");      }    }    String confirmationThresholdString = Utils.getOption('C', options);    if (confirmationThresholdString.length() != 0) {      try {	m_confirmationThreshold 	  = (new Double(confirmationThresholdString)).doubleValue();      } catch (Exception e) {	throw new Exception("Invalid value for -C option: "			    + e.getMessage() + ".");      }      if (m_confirmationThreshold < 0 || m_confirmationThreshold > 1) {	throw new Exception("Confirmation threshold has to be between "			    + "zero and one!");      }      if (bestString.length() != 0) {	throw new Exception("Specifying both a number of confirmation "			    + "values and a confirmation threshold "			    + "doesn't make sense!");      }      if (m_confirmationThreshold != 0) {	m_best = 0;      }    }    String noiseThresholdString = Utils.getOption('N', options);    if (noiseThresholdString.length() != 0) {      try {	m_noiseThreshold = (new Double(noiseThresholdString)).doubleValue();      } catch (Exception e) {	throw new Exception("Invalid value for -N option: "			    + e.getMessage() + ".");      }      if (m_noiseThreshold < 0 || m_noiseThreshold > 1) {	throw new Exception("Noise threshold has to be between "			    + "zero and one!");      }    }    /* Search space and language bias options. */    m_repeat = Utils.getFlag('R', options);    String numLiteralsString = Utils.getOption('L', options);    if (numLiteralsString.length() != 0) {      try {	m_numLiterals = Integer.parseInt(numLiteralsString);      } catch (Exception e) {	throw new Exception("Invalid value for -L option: "			    + e.getMessage() + ".");      }      if (m_numLiterals < 1) {	throw new Exception("Number of literals has to be "			    + "greater than one!");      }    }    String negationString = Utils.getOption('G', options);    if (negationString.length() != 0) {      SelectedTag selected;      int tag;      try {	tag = Integer.parseInt(negationString);      } catch (Exception e) {	throw new Exception("Invalid value for -G option: "			    + e.getMessage() + ".");      }      try {	selected = new SelectedTag(tag, TAGS_NEGATION);      } catch (Exception e) {	throw new Exception("Value for -G option has to be "			    + "between zero and three!");      }      setNegation(selected);    }    m_classification = Utils.getFlag('S', options);    String classIndexString = Utils.getOption('c', options);    if (classIndexString.length() != 0) {      try {	m_classIndex = Integer.parseInt(classIndexString);      } catch (Exception e) {	throw new Exception("Invalid value for -c option: "			    + e.getMessage() + ".");      }    }    m_horn = Utils.getFlag('H', options);    if (m_horn && (m_negation != NONE)) {      throw new Exception("Considering horn clauses doesn't make sense "			  + "if negation allowed!");    }        /* Subsumption tests options. */    m_equivalent = !(Utils.getFlag('E', options));    m_sameClause = !(Utils.getFlag('M', options));    m_subsumption = !(Utils.getFlag('T', options));    /* Missing values options. */    String missingString = Utils.getOption('I', options);    if (missingString.length() != 0) {      SelectedTag selected;      int tag;      try {	tag = Integer.parseInt(missingString);      } catch (Exception e) {	throw new Exception("Invalid value for -I option: "			    + e.getMessage() + ".");      }      try {	selected = new SelectedTag(tag, TAGS_MISSING);      } catch (Exception e) {	throw new Exception("Value for -I option has to be "			    + "between zero and two!");      }      setMissingValues(selected);    }    /* ROC analysis. */    m_roc = Utils.getFlag('O', options);    /* Individual-based learning. */    m_partsString = Utils.getOption('p', options);    if (m_partsString.length() != 0) {      Reader reader;      try {	reader = new BufferedReader(new FileReader(m_partsString));      } catch (Exception e) {	throw new Exception("Can't open file " + e.getMessage() + ".");      }      m_parts = new Instances(reader);	    }    /* Values output. */    String printValuesString = Utils.getOption('P', options);    if (printValuesString.length() != 0) {      SelectedTag selected;      int tag;      try {	tag = Integer.parseInt(printValuesString);      } catch (Exception e) {	throw new Exception("Invalid value for -P option: "			    + e.getMessage() + ".");      }      try {	selected = new SelectedTag(tag, TAGS_VALUES);      } catch (Exception e) {	throw new Exception("Value for -P option has to be "			    + "between zero and two!");      }      setValuesOutput(selected);    }  }  /**   * Gets the current settings of the Tertius object.   *   * @return An array of strings suitable for passing to setOptions.   */  public String [] getOptions() {        String [] options = new String [24];    int current = 0;        /* Pruning options. */    options[current++] = "-K"; options[current++] = "" + m_best;    options[current++] = "-F"; options[current++] = "" + m_frequencyThreshold;    options[current++] = "-C"; options[current++] = "" + m_confirmationThreshold;    options[current++] = "-N"; options[current++] = "" + m_noiseThreshold;    /* Search space and language bias options. */    if (m_repeat) {      options[current++] = "-R";    }    options[current++] = "-L"; options[current++] = "" + m_numLiterals;    options[current++] = "-G"; options[current++] = "" + m_negation;    if (m_classification) {      options[current++] = "-S";    }    options[current++] = "-c"; options[current++] = "" + m_classIndex;    if (m_horn) {      options[current++] = "-H";    }    /* Subsumption tests options. */    if (!m_equivalent) {      options[current++] = "-E";    }    if (!m_sameClause) {      options[current++] = "-M";    }    if (!m_subsumption) {      options[current++] = "-T";    }    /* Missing values options. */    options[current++] = "-I"; options[current++] = "" + m_missing;    /* ROC analysis. */    if (m_roc) {      options[current++] = "-O";    }    /* Individual-based learning. */    options[current++] = "-p"; options[current++] = "" + m_partsString;    /* Values output. */    options[current++] = "-P"; options[current++] = "" + m_printValues;    while (current < options.length) {      options[current++] = "";    }    return options;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String confirmationValuesTipText() {    return "Number of best confirmation values to find.";  }  /**   * Get the value of confirmationValues.   *   * @return Value of confirmationValues.   */  public int getConfirmationValues() {    return m_best;  }  /**   * Set the value of confirmationValues.   *   * @param v  Value to assign to confirmationValues.   */  public void setConfirmationValues(int v) {    m_best = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String frequencyThresholdTipText() {        return "Minimum proportion of instances satisfying head and body of rules";  }  /**   * Get the value of frequencyThreshold.   *   * @return Value of frequencyThreshold.   */  public double getFrequencyThreshold() {        return m_frequencyThreshold;  }  /**   * Set the value of frequencyThreshold.   *   * @param v  Value to assign to frequencyThreshold.   */  public void setFrequencyThreshold(double v) {        m_frequencyThreshold = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String confirmationThresholdTipText() {        return "Minimum confirmation of the rules.";  }  /**   * Get the value of confirmationThreshold.   *   * @return Value of confirmationThreshold.   */  public double getConfirmationThreshold() {        return m_confirmationThreshold;  }  /**   * Set the value of confirmationThreshold.   *   * @param v  Value to assign to confirmationThreshold.   */  public void setConfirmationThreshold(double v) {        m_confirmationThreshold = v;    if (v != 0) {      m_best = 0;    }  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String noiseThresholdTipText() {        return "Maximum proportion of counter-instances of rules. "      + "If set to 0, only satisfied rules will be given.";  }  /**   * Get the value of noiseThreshold.   *   * @return Value of noiseThreshold.   */  public double getNoiseThreshold() {        return m_noiseThreshold;  }  /**   * Set the value of noiseThreshold.   *   * @param v  Value to assign to noiseThreshold.   */  public void setNoiseThreshold(double v) {        m_noiseThreshold = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String repeatLiteralsTipText() {    return "Repeated attributes allowed.";  }  /**   * Get the value of repeatLiterals.   *   * @return Value of repeatLiterals.   */  public boolean getRepeatLiterals() {        return m_repeat;  }  /**   * Set the value of repeatLiterals.   *   * @param v  Value to assign to repeatLiterals.   */  public void setRepeatLiterals(boolean v) {        m_repeat = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String numberLiteralsTipText() {        return "Maximum number of literals in a rule.";  }  /**   * Get the value of numberLiterals.   *   * @return Value of numberLiterals.   */  public int getNumberLiterals() {    return m_numLiterals;  }  /**   * Set the value of numberLiterals.   *   * @param v  Value to assign to numberLiterals.   */  public void setNumberLiterals(int v) {        m_numLiterals = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String negationTipText() {        return "Set the type of negation allowed in the rule. "      + "Negation can be allowed in the body, in the head, in both "      + "or in none.";  }  /**   * Get the value of negation.   *   * @return Value of negation.   */  public SelectedTag getNegation() {        return new SelectedTag(m_negation, TAGS_NEGATION);  }  /**   * Set the value of negation.   *   * @param v  Value to assign to negation.   */  public void setNegation(SelectedTag v) {        if (v.getTags() == TAGS_NEGATION) {      m_negation = v.getSelectedTag().getID();    }  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String classificationTipText() {        return "Find only rules with the class in the head.";  }  /**   * Get the value of classification.   *   * @return Value of classification.   */  public boolean getClassification() {    return m_classification;  }  /**   * Set the value of classification.   *   * @param v  Value to assign to classification.   */  public void setClassification(boolean v) {    m_classification = v;  }  /**   * Returns the tip text for this property.   *   * @return Tip text for this property suitable for   * displaying in the explorer/experimenter GUI.   */  public String classIndexTipText() {    return "Index of the class attribute. If set to 0, the class will be the last attribute.";  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -