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

📄 fat.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    newVector.	addElement(new Option("\tUse binary splits only.",			      "B", 0, "-B"));    newVector.        addElement(new Option("\tDon't perform subtree raising.",			      "S", 0, "-S"));    newVector.        addElement(new Option("\tDo not clean up after the tree has been built.",			      "L", 0, "-L"));    newVector.        addElement(new Option("\tLaplace smoothing for predicted probabilities.",			      "A", 0, "-A"));    newVector.	addElement(new Option("\tUse sampling for selection of instances.",			      "P", 0, "-P"));    return newVector.elements();  }  /**   * 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 {        // Other options    String minNumString = Utils.getOption('M', options);    if (minNumString.length() != 0) {      m_minNumObj = Integer.parseInt(minNumString);    } else {      m_minNumObj = 2;    }    m_binarySplits = Utils.getFlag('B', options);    m_useLaplace = Utils.getFlag('A', options);    // Pruning options    m_unpruned = Utils.getFlag('U', options);    m_subtreeRaising = !Utils.getFlag('S', options);    m_noCleanup = Utils.getFlag('L', options);    if ((m_unpruned) && (!m_subtreeRaising)) {      throw new Exception("Subtree raising doesn't need to be unset for unpruned tree!");    }    m_reducedErrorPruning = Utils.getFlag('R', options);    if ((m_unpruned) && (m_reducedErrorPruning)) {      throw new Exception("Unpruned tree and reduced error pruning can't be selected " +			  "simultaneously!");    }    String confidenceString = Utils.getOption('C', options);    if (confidenceString.length() != 0) {      if (m_reducedErrorPruning) {	throw new Exception("Setting the confidence doesn't make sense " +			    "for reduced error pruning.");      } else if (m_unpruned) {	throw new Exception("Doesn't make sense to change confidence for unpruned "			    +"tree!");      } else {	m_CF = (new Float(confidenceString)).floatValue();	if ((m_CF <= 0) || (m_CF >= 1)) {	  throw new Exception("Confidence 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" +			    " doesn't make sense if" +			    " reduced error pruning is not selected.");      } else {	m_numFolds = Integer.parseInt(numFoldsString);      }    } else {      m_numFolds = 3;    }        //=============== BEGIN EDIT melville ===============    String selectionScheme = Utils.getOption('E', options);    if (selectionScheme.length() != 0) {	setSelectionScheme(Integer.parseInt(selectionScheme));    } else {	setSelectionScheme(0);    }        m_UseSampling = Utils.getFlag('P', options);    //=============== END EDIT melville ===============  }        //=============== BEGIN EDIT melville ===============            /**     * Get the value of useSampling.     * @return value of useSampling.     */    public boolean getUseSampling() {	return m_UseSampling;    }        /**     * Set the value of useSampling.     * @param v  Value to assign to useSampling.     */    public void setUseSampling(boolean  v) {	m_UseSampling = v;    }        /**     * Get the value of m_SelectionScheme.     * @return value of m_SelectionScheme.     */    public int getSelectionScheme() {	return m_SelectionScheme;    }        /**     * Set the value of m_SelectionScheme.     * @param v  Value to assign to m_SelectionScheme.     */    public void setSelectionScheme(int  v) {	m_SelectionScheme = v;    }    //=============== END EDIT melville ===============      /**   * Gets the current settings of the Classifier.   *   * @return an array of strings suitable for passing to setOptions   */  public String [] getOptions() {      //=============== BEGIN EDIT melville ===============    String [] options = new String [12];    //=============== END EDIT melville ===============    int current = 0;    if (m_noCleanup) {      options[current++] = "-L";    }    if (m_unpruned) {      options[current++] = "-U";    } else {      if (!m_subtreeRaising) {	options[current++] = "-S";      }      if (m_reducedErrorPruning) {	options[current++] = "-R";	options[current++] = "-N"; options[current++] = "" + m_numFolds;      } else {	options[current++] = "-C"; options[current++] = "" + m_CF;      }    }    if (m_binarySplits) {      options[current++] = "-B";    }    options[current++] = "-M"; options[current++] = "" + m_minNumObj;    if (m_useLaplace) {      options[current++] = "-A";    }        //=============== BEGIN EDIT melville ===============    options[current++] = "-E"; options[current++] = "" + getSelectionScheme();    if (m_UseSampling) {	options[current++] = "-P";    }    //=============== END EDIT melville ===============        while (current < options.length) {      options[current++] = "";    }    return options;  }    /**   * Get the value of useLaplace.   *   * @return Value of useLaplace.   */  public boolean getUseLaplace() {        return m_useLaplace;  }    /**   * Set the value of useLaplace.   *   * @param newuseLaplace Value to assign to useLaplace.   */  public void setUseLaplace(boolean newuseLaplace) {        m_useLaplace = newuseLaplace;  }    /**   * Returns a description of the classifier.   */  public String toString() {    if (m_root == null) {      return "No classifier built";    }    if (m_unpruned)      return "J48 unpruned tree\n------------------\n" + m_root.toString();    else      return "J48 pruned tree\n------------------\n" + m_root.toString();  }  /**   * Returns a superconcise version of the model   */  public String toSummaryString() {    return "Number of leaves: " + m_root.numLeaves() + "\n"         + "Size of the tree: " + m_root.numNodes() + "\n";  }  /**   * Returns the size of the tree   * @return the size of the tree   */  public double measureTreeSize() {    return m_root.numNodes();  }  /**   * Returns the number of leaves   * @return the number of leaves   */  public double measureNumLeaves() {    return m_root.numLeaves();  }  /**   * Returns the number of rules (same as number of leaves)   * @return the number of rules   */  public double measureNumRules() {    return m_root.numLeaves();  }    /**   * Returns an enumeration of the additional measure names   * @return an enumeration of the measure names   */  public Enumeration enumerateMeasures() {    Vector newVector = new Vector(3);    newVector.addElement("measureTreeSize");    newVector.addElement("measureNumLeaves");    newVector.addElement("measureNumRules");    return newVector.elements();  }  /**   * Returns the value of the named measure   * @param measureName the name of the measure to query for its value   * @return the value of the named measure   * @exception IllegalArgumentException if the named measure is not supported   */  public double getMeasure(String additionalMeasureName) {    if (additionalMeasureName.compareTo("measureNumRules") == 0) {      return measureNumRules();    } else if (additionalMeasureName.compareTo("measureTreeSize") == 0) {      return measureTreeSize();    } else if (additionalMeasureName.compareTo("measureNumLeaves") == 0) {      return measureNumLeaves();    } else {      throw new IllegalArgumentException(additionalMeasureName 			  + " not supported (j48)");    }  }  /**   * Get the value of unpruned.   *   * @return Value of unpruned.   */  public boolean getUnpruned() {        return m_unpruned;  }    /**   * Set the value of unpruned. Turns reduced-error pruning   * off if set.   * @param v  Value to assign to unpruned.   */  public void setUnpruned(boolean v) {    if (v) {      m_reducedErrorPruning = false;    }    m_unpruned = v;  }    /**   * Get the value of CF.   *   * @return Value of CF.   */  public float getConfidenceFactor() {        return m_CF;  }    /**   * Set the value of CF.   *   * @param v  Value to assign to CF.   */  public void setConfidenceFactor(float v) {        m_CF = v;  }    /**   * Get the value of minNumObj.   *   * @return Value of minNumObj.   */  public int getMinNumObj() {        return m_minNumObj;  }    /**   * Set the value of minNumObj.   *   * @param v  Value to assign to minNumObj.   */  public void setMinNumObj(int v) {        m_minNumObj = v;  }    /**   * Get the value of reducedErrorPruning.    *   * @return Value of reducedErrorPruning.   */  public boolean getReducedErrorPruning() {        return m_reducedErrorPruning;  }    /**   * Set the value of reducedErrorPruning. Turns   * unpruned trees off if set.   *   * @param v  Value to assign to reducedErrorPruning.   */  public void setReducedErrorPruning(boolean v) {        if (v) {      m_unpruned = false;    }    m_reducedErrorPruning = v;  }    /**   * Get the value of numFolds.   *   * @return Value of numFolds.   */  public int getNumFolds() {        return m_numFolds;  }    /**   * Set the value of numFolds.   *   * @param v  Value to assign to numFolds.   */  public void setNumFolds(int v) {        m_numFolds = v;  }    /**   * Get the value of binarySplits.   *   * @return Value of binarySplits.   */  public boolean getBinarySplits() {        return m_binarySplits;  }    /**   * Set the value of binarySplits.   *   * @param v  Value to assign to binarySplits.   */  public void setBinarySplits(boolean v) {        m_binarySplits = v;  }    /**   * Get the value of subtreeRaising.   *   * @return Value of subtreeRaising.   */  public boolean getSubtreeRaising() {        return m_subtreeRaising;  }    /**   * Set the value of subtreeRaising.   *   * @param v  Value to assign to subtreeRaising.   */  public void setSubtreeRaising(boolean v) {        m_subtreeRaising = v;  }    /**   * Check whether instance data is to be saved.   *   * @return true if instance data is saved   */  public boolean getSaveInstanceData() {        return m_noCleanup;  }    /**   * Set whether instance data is to be saved.   * @param v true if instance data is to be saved   */  public void setSaveInstanceData(boolean v) {        m_noCleanup = v;  }   /**   * Main method for testing this class   *   * @param String options    */  public static void main(String [] argv){    try {      System.out.println(Evaluation.evaluateModel(new FAT(), argv));    } catch (Exception e) {      System.err.println(e.getMessage());    }  }}  

⌨️ 快捷键说明

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