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

📄 costsensitiveclassifiersplitevaluator.java

📁 Java 编写的多种数据挖掘算法 包括聚类、分类、预处理等
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *    CostSensitiveClassifierSplitEvaluator.java *    Copyright (C) 2002 University of Waikato * */package weka.experiment;import weka.classifiers.Classifier;import weka.classifiers.CostMatrix;import weka.classifiers.Evaluation;import weka.core.AdditionalMeasureProducer;import weka.core.Attribute;import weka.core.Instance;import weka.core.Instances;import weka.core.Option;import weka.core.Summarizable;import weka.core.Utils;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.lang.management.ManagementFactory;import java.lang.management.ThreadMXBean;import java.util.Enumeration;import java.util.Vector;/** <!-- globalinfo-start --> * SplitEvaluator that produces results for a classification scheme on a nominal class attribute, including weighted misclassification costs. * <p/> <!-- globalinfo-end --> * <!-- options-start --> * Valid options are: <p/> *  * <pre> -W &lt;class name&gt; *  The full class name of the classifier. *  eg: weka.classifiers.bayes.NaiveBayes</pre> *  * <pre> -C &lt;index&gt; *  The index of the class for which IR statistics *  are to be output. (default 1)</pre> *  * <pre> -I &lt;index&gt; *  The index of an attribute to output in the *  results. This attribute should identify an *  instance in order to know which instances are *  in the test set of a cross validation. if 0 *  no output (default 0).</pre> *  * <pre> -P *  Add target and prediction columns to the result *  for each fold.</pre> *  * <pre>  * Options specific to classifier weka.classifiers.rules.ZeroR: * </pre> *  * <pre> -D *  If set, classifier is run in debug mode and *  may output additional info to the console</pre> *  * <pre> -D &lt;directory&gt; *  Name of a directory to search for cost files when loading *  costs on demand (default current directory).</pre> *  <!-- options-end --> * * All options after -- will be passed to the classifier. * * @author Len Trigg (len@reeltwo.com) * @version $Revision: 1.14 $ */public class CostSensitiveClassifierSplitEvaluator   extends ClassifierSplitEvaluator {   /** for serialization */  static final long serialVersionUID = -8069566663019501276L;  /**    * The directory used when loading cost files on demand, null indicates   * current directory    */  protected File m_OnDemandDirectory = new File(System.getProperty("user.dir"));  /** The length of a result */  private static final int RESULT_SIZE = 27; //23;  /**   * Returns a string describing this split evaluator   * @return a description of the split evaluator suitable for   * displaying in the explorer/experimenter gui   */  public String globalInfo() {    return " SplitEvaluator that produces results for a classification scheme "      +"on a nominal class attribute, including weighted misclassification "      +"costs.";  }  /**   * Returns an enumeration describing the available options..   *   * @return an enumeration of all the available options.   */  public Enumeration listOptions() {    Vector newVector = new Vector(1);    Enumeration enu = super.listOptions();    while (enu.hasMoreElements()) {      newVector.addElement(enu.nextElement());    }    newVector.addElement(new Option(              "\tName of a directory to search for cost files when loading\n"              +"\tcosts on demand (default current directory).",              "D", 1, "-D <directory>"));    return newVector.elements();  }  /**   * Parses a given list of options. <p/>   *   <!-- options-start -->   * Valid options are: <p/>   *    * <pre> -W &lt;class name&gt;   *  The full class name of the classifier.   *  eg: weka.classifiers.bayes.NaiveBayes</pre>   *    * <pre> -C &lt;index&gt;   *  The index of the class for which IR statistics   *  are to be output. (default 1)</pre>   *    * <pre> -I &lt;index&gt;   *  The index of an attribute to output in the   *  results. This attribute should identify an   *  instance in order to know which instances are   *  in the test set of a cross validation. if 0   *  no output (default 0).</pre>   *    * <pre> -P   *  Add target and prediction columns to the result   *  for each fold.</pre>   *    * <pre>    * Options specific to classifier weka.classifiers.rules.ZeroR:   * </pre>   *    * <pre> -D   *  If set, classifier is run in debug mode and   *  may output additional info to the console</pre>   *    * <pre> -D &lt;directory&gt;   *  Name of a directory to search for cost files when loading   *  costs on demand (default current directory).</pre>   *    <!-- options-end -->   *   * All options after -- will be passed to the classifier.   *   * @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 demandDir = Utils.getOption('D', options);    if (demandDir.length() != 0) {      setOnDemandDirectory(new File(demandDir));    }    super.setOptions(options);  }  /**   * Gets the current settings of the Classifier.   *   * @return an array of strings suitable for passing to setOptions   */  public String [] getOptions() {    String [] superOptions = super.getOptions();    String [] options = new String [superOptions.length + 3];    int current = 0;    options[current++] = "-D";    options[current++] = "" + getOnDemandDirectory();    System.arraycopy(superOptions, 0, options, current, 		     superOptions.length);    current += superOptions.length;    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 onDemandDirectoryTipText() {    return "The directory to look in for cost files. This directory will be "      +"searched for cost files when loading on demand.";  }  /**   * Returns the directory that will be searched for cost files when   * loading on demand.   *   * @return The cost file search directory.   */  public File getOnDemandDirectory() {    return m_OnDemandDirectory;  }  /**   * Sets the directory that will be searched for cost files when   * loading on demand.   *   * @param newDir The cost file search directory.   */  public void setOnDemandDirectory(File newDir) {    if (newDir.isDirectory()) {      m_OnDemandDirectory = newDir;    } else {      m_OnDemandDirectory = new File(newDir.getParent());    }  }  /**   * Gets the data types of each of the result columns produced for a    * single run. The number of result fields must be constant   * for a given SplitEvaluator.   *   * @return an array containing objects of the type of each result column.    * The objects should be Strings, or Doubles.   */  public Object [] getResultTypes() {    int addm = (m_AdditionalMeasures != null) 

⌨️ 快捷键说明

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