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

📄 svmattributeeval.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. *//* *    SVMAttributeEval.java *    Copyright (C) 2002 University of Waikato, Hamilton, New Zealand * */package weka.attributeSelection;import weka.classifiers.functions.SMO;import weka.core.Capabilities;import weka.core.Instances;import weka.core.Option;import weka.core.OptionHandler;import weka.core.SelectedTag;import weka.core.TechnicalInformation;import weka.core.TechnicalInformationHandler;import weka.core.Utils;import weka.core.Capabilities.Capability;import weka.core.TechnicalInformation.Field;import weka.core.TechnicalInformation.Type;import weka.filters.Filter;import weka.filters.unsupervised.attribute.MakeIndicator;import java.util.ArrayList;import java.util.Enumeration;import java.util.Iterator;import java.util.Vector;/**  <!-- globalinfo-start --> * SVMAttributeEval :<br/> * <br/> * Evaluates the worth of an attribute by using an SVM classifier. Attributes are ranked by the square of the weight assigned by the SVM. Attribute selection for multiclass problems is handled by ranking attributes for each class seperately using a one-vs-all method and then "dealing" from the top of each pile to give a final ranking.<br/> * <br/> * For more information see:<br/> * <br/> * I. Guyon, J. Weston, S. Barnhill, V. Vapnik (2002). Gene selection for cancer classification using support vector machines. Machine Learning. 46:389-422. * <p/> <!-- globalinfo-end --> * <!-- technical-bibtex-start --> * BibTeX: * <pre> * &#64;article{Guyon2002, *    author = {I. Guyon and J. Weston and S. Barnhill and V. Vapnik}, *    journal = {Machine Learning}, *    pages = {389-422}, *    title = {Gene selection for cancer classification using support vector machines}, *    volume = {46}, *    year = {2002} * } * </pre> * <p/> <!-- technical-bibtex-end --> * <!-- options-start --> * Valid options are: <p/> *  * <pre> -X &lt;constant rate of elimination&gt; *  Specify the constant rate of attribute *  elimination per invocation of *  the support vector machine. *  Default = 1.</pre> *  * <pre> -Y &lt;percent rate of elimination&gt; *  Specify the percentage rate of attributes to *  elimination per invocation of *  the support vector machine. *  Trumps constant rate (above threshold). *  Default = 0.</pre> *  * <pre> -Z &lt;threshold for percent elimination&gt; *  Specify the threshold below which  *  percentage attribute elimination *  reverts to the constant method.</pre> *  * <pre> -P &lt;epsilon&gt; *  Specify the value of P (epsilon *  parameter) to pass on to the *  support vector machine. *  Default = 1.0e-25</pre> *  * <pre> -T &lt;tolerance&gt; *  Specify the value of T (tolerance *  parameter) to pass on to the *  support vector machine. *  Default = 1.0e-10</pre> *  * <pre> -C &lt;complexity&gt; *  Specify the value of C (complexity *  parameter) to pass on to the *  support vector machine. *  Default = 1.0</pre> *  * <pre> -N *  Whether the SVM should 0=normalize/1=standardize/2=neither. *  (default 0=normalize)</pre> *  <!-- options-end --> * * @author Eibe Frank (eibe@cs.waikato.ac.nz) * @author Mark Hall (mhall@cs.waikato.ac.nz) * @author Kieran Holland * @version $Revision: 1.26 $ */public class SVMAttributeEval   extends AttributeEvaluator  implements OptionHandler, TechnicalInformationHandler {    /** for serialization */  static final long serialVersionUID = -6489975709033967447L;  /** The attribute scores */  private double[] m_attScores;  /** Constant rate of attribute elimination per iteration */  private int m_numToEliminate = 1;  /** Percentage rate of attribute elimination, trumps constant      rate (above threshold), ignored if = 0  */  private int m_percentToEliminate = 0;  /** Threshold below which percent elimination switches to      constant elimination */  private int m_percentThreshold = 0;  /** Complexity parameter to pass on to SMO */  private double m_smoCParameter = 1.0;  /** Tolerance parameter to pass on to SMO */  private double m_smoTParameter = 1.0e-10;  /** Epsilon parameter to pass on to SMO */  private double m_smoPParameter = 1.0e-25;  /** Filter parameter to pass on to SMO */  private int m_smoFilterType = 0;  /**   * Returns a string describing this attribute evaluator   * @return a description of the evaluator suitable for   * displaying in the explorer/experimenter gui   */  public String globalInfo() {    return "SVMAttributeEval :\n\nEvaluates the worth of an attribute by "      + "using an SVM classifier. Attributes are ranked by the square of the "      + "weight assigned by the SVM. Attribute selection for multiclass "      + "problems is handled by ranking attributes for each class seperately "      + "using a one-vs-all method and then \"dealing\" from the top of "      + "each pile to give a final ranking.\n\n"      + "For more information see:\n\n"      + getTechnicalInformation().toString();  }  /**   * Returns an instance of a TechnicalInformation object, containing    * detailed information about the technical background of this class,   * e.g., paper reference or book this class is based on.   *    * @return the technical information about this class   */  public TechnicalInformation getTechnicalInformation() {    TechnicalInformation        result;        result = new TechnicalInformation(Type.ARTICLE);    result.setValue(Field.AUTHOR, "I. Guyon and J. Weston and S. Barnhill and V. Vapnik");    result.setValue(Field.YEAR, "2002");    result.setValue(Field.TITLE, "Gene selection for cancer classification using support vector machines");    result.setValue(Field.JOURNAL, "Machine Learning");    result.setValue(Field.VOLUME, "46");    result.setValue(Field.PAGES, "389-422");        return result;  }  /**   * Constructor   */  public SVMAttributeEval() {    resetOptions();  }  /**   * Returns an enumeration describing all the available options   *   * @return an enumeration of options   */  public Enumeration listOptions() {    Vector newVector = new Vector(4);    newVector.addElement(                         new Option(                                    "\tSpecify the constant rate of attribute\n"                                    + "\telimination per invocation of\n"                                    + "\tthe support vector machine.\n"                                    + "\tDefault = 1.",                                    "X",                                    1,                                    "-X <constant rate of elimination>"));    newVector.addElement(                         new Option(                                    "\tSpecify the percentage rate of attributes to\n"                                    + "\telimination per invocation of\n"                                    + "\tthe support vector machine.\n"                                    + "\tTrumps constant rate (above threshold).\n"                                    + "\tDefault = 0.",                                    "Y",                                    1,                                    "-Y <percent rate of elimination>"));    newVector.addElement(                         new Option(                                    "\tSpecify the threshold below which \n"                                    + "\tpercentage attribute elimination\n"                                    + "\treverts to the constant method.",                                    "Z",                                    1,                                    "-Z <threshold for percent elimination>"));    newVector.addElement(                         new Option(                                    "\tSpecify the value of P (epsilon\n"                                    + "\tparameter) to pass on to the\n"                                    + "\tsupport vector machine.\n"                                    + "\tDefault = 1.0e-25",                                    "P",                                    1,                                    "-P <epsilon>"));    newVector.addElement(                         new Option(                                    "\tSpecify the value of T (tolerance\n"                                    + "\tparameter) to pass on to the\n"                                    + "\tsupport vector machine.\n"                                    + "\tDefault = 1.0e-10",                                    "T",                                    1,                                    "-T <tolerance>"));    newVector.addElement(                         new Option(                                    "\tSpecify the value of C (complexity\n"                                    + "\tparameter) to pass on to the\n"                                    + "\tsupport vector machine.\n"                                    + "\tDefault = 1.0",                                    "C",                                    1,                                    "-C <complexity>"));    newVector.addElement(new Option("\tWhether the SVM should "                                    + "0=normalize/1=standardize/2=neither.\n"                                    + "\t(default 0=normalize)",                                    "N",                                    1,                                    "-N"));    return newVector.elements();  }  /**   * Parses a given list of options. <p/>   *   <!-- options-start -->   * Valid options are: <p/>   *    * <pre> -X &lt;constant rate of elimination&gt;   *  Specify the constant rate of attribute   *  elimination per invocation of   *  the support vector machine.   *  Default = 1.</pre>   *    * <pre> -Y &lt;percent rate of elimination&gt;   *  Specify the percentage rate of attributes to   *  elimination per invocation of   *  the support vector machine.   *  Trumps constant rate (above threshold).   *  Default = 0.</pre>   *    * <pre> -Z &lt;threshold for percent elimination&gt;   *  Specify the threshold below which    *  percentage attribute elimination   *  reverts to the constant method.</pre>   *    * <pre> -P &lt;epsilon&gt;   *  Specify the value of P (epsilon   *  parameter) to pass on to the   *  support vector machine.   *  Default = 1.0e-25</pre>   *    * <pre> -T &lt;tolerance&gt;   *  Specify the value of T (tolerance   *  parameter) to pass on to the   *  support vector machine.   *  Default = 1.0e-10</pre>   *    * <pre> -C &lt;complexity&gt;   *  Specify the value of C (complexity   *  parameter) to pass on to the   *  support vector machine.   *  Default = 1.0</pre>   *    * <pre> -N   *  Whether the SVM should 0=normalize/1=standardize/2=neither.   *  (default 0=normalize)</pre>   *    <!-- options-end -->   *   * @param options the list of options as an array of strings   * @throws Exception if an error occurs   */  public void setOptions(String[] options) throws Exception {    String optionString;    optionString = Utils.getOption('X', options);    if (optionString.length() != 0) {      setAttsToEliminatePerIteration(Integer.parseInt(optionString));    }    optionString = Utils.getOption('Y', options);    if (optionString.length() != 0) {      setPercentToEliminatePerIteration(Integer.parseInt(optionString));    }    optionString = Utils.getOption('Z', options);    if (optionString.length() != 0) {      setPercentThreshold(Integer.parseInt(optionString));    }    optionString = Utils.getOption('P', options);    if (optionString.length() != 0) {      setEpsilonParameter((new Double(optionString)).doubleValue());    }    optionString = Utils.getOption('T', options);    if (optionString.length() != 0) {      setToleranceParameter((new Double(optionString)).doubleValue());    }    optionString = Utils.getOption('C', options);    if (optionString.length() != 0) {      setComplexityParameter((new Double(optionString)).doubleValue());    }    optionString = Utils.getOption('N', options);    if (optionString.length() != 0) {      setFilterType(new SelectedTag(Integer.parseInt(optionString), SMO.TAGS_FILTER));    } else {      setFilterType(new SelectedTag(SMO.FILTER_NORMALIZE, SMO.TAGS_FILTER));    }    Utils.checkForRemainingOptions(options);  }  /**   * Gets the current settings of SVMAttributeEval   *   * @return an array of strings suitable for passing to setOptions()    */  public String[] getOptions() {    String[] options = new String[14];    int current = 0;    options[current++] = "-X";    options[current++] = "" + getAttsToEliminatePerIteration();    options[current++] = "-Y";    options[current++] = "" + getPercentToEliminatePerIteration();    options[current++] = "-Z";    options[current++] = "" + getPercentThreshold();                    options[current++] = "-P";    options[current++] = "" + getEpsilonParameter();    options[current++] = "-T";    options[current++] = "" + getToleranceParameter();              options[current++] = "-C";    options[current++] = "" + getComplexityParameter();             options[current++] = "-N";    options[current++] = "" + m_smoFilterType;              while (current < options.length) {      options[current++] = "";    }    return options;  }  //________________________________________________________________________  /**   * Returns a tip text for this property suitable for display in the   * GUI

⌨️ 快捷键说明

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