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

📄 tertius.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    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) throws Exception {

    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.";
  }

  /**
   * Get the value of classIndex.
   *
   * @return Value of classIndex.
   */
  public int getClassIndex() {

    return m_classIndex;
  }

  /**
   * Set the value of classIndex.
   *
   * @param v  Value to assign to classIndex.
   */
  public void setClassIndex(int v) {

    m_classIndex = v;
  }

  /**
   * Returns the tip text for this property.
   *
   * @return Tip text for this property suitable for
   * displaying in the explorer/experimenter GUI.
   */
  public String hornClausesTipText() {
    
    return "Find rules with a single conclusion literal only.";
  }

  /**
   * Get the value of hornClauses.
   *
   * @return Value of hornClauses.
   */
  public boolean getHornClauses() {

    return m_horn;
  }

  /**
   * Set the value of hornClauses.
   *
   * @param v  Value to assign to hornClauses.
   */
  public void setHornClauses(boolean v) {

    m_horn = v;
  }
  
  /**
   * Returns the tip text for this property.

⌨️ 快捷键说明

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