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

📄 svmattributeeval.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 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 Eibe Frank *    Mod by Kieran Holland * */package weka.attributeSelection;import java.io.*;import java.util.*;import weka.core.*;import weka.classifiers.functions.SMO;import weka.filters.Filter;import weka.filters.unsupervised.attribute.MakeIndicator;import weka.attributeSelection.*;/**  * Class for Evaluating attributes individually by using the 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.<p> * * Valid options are: <p> * * -X <constant rate of elimination> <br> * Specify constant rate at which attributes are eliminated per invocation * of the support vector machine. Default = 1.<p> *  * -Y <percent rate of elimination> <br> * Specify the percentage rate at which attributes are eliminated per invocation * of the support vector machine. This setting trumps the constant rate setting.  * Default = 0 (percentage rate ignored).<p> * * -Z <threshold for percent elimination> <br> * Specify the threshold below which the percentage elimination method * reverts to the constant elimination method.<p> * * -C <complexity parameter> <br> * Specify the value of C - the complexity parameter to be passed on * to the support vector machine. <p> *  * -P <episilon> <br> * Sets the epsilon for round-off error. (default 1.0e-25)<p> * * -T <tolerance> <br> * Sets the tolerance parameter. (default 1.0e-10)<p> * * @author Eibe Frank (eibe@cs.waikato.ac.nz) * @author Mark Hall (mhall@cs.waikato.ac.nz) * @version $Revision: 1.1.1.1 $ */public class SVMAttributeEval extends AttributeEvaluator  implements OptionHandler {  /** 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.\n";  }  /**   * 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.\n",				    "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. "				    + "(default 0=normalize)",				    "N",				    1,				    "-N"));    return newVector.elements();  }  /**   * Parses a given list of options   *   * Valid options are: <p>   *   * -X <constant rate of elimination> <br>   * Specify constant rate at which attributes are eliminated per invocation   * of the support vector machine. Default = 1.<p>   *    * -Y <percent rate of elimination> <br>   * Specify the percentage rate at which attributes are eliminated per invocation   * of the support vector machine. This setting trumps the constant rate setting.    * Default = 0 (percentage rate ignored).<p>   *   * -Z <threshold for percent elimination> <br>   * Specify the threshold below which the percentage elimination method   * reverts to the constant elimination method.<p>   *   * -C <complexity parameter> <br>   * Specify the value of C - the complexity parameter to be passed on   * to the support vector machine. <p>   *    * -P <episilon> <br>   * Sets the epsilon for round-off error. (default 1.0e-25)<p>   *   * -T <tolerance> <br>   * Sets the tolerance parameter. (default 1.0e-10)<p>   *   * -N <0|1|2> <br>   * Whether the SVM should 0=normalize/1=standardize/2=neither. (default 0=normalize)<p>   *   * @param options the list of options as an array of strings   * @exception 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   *   * @return tip text string describing this property   */  public String attsToEliminatePerIterationTipText() {    return "Constant rate of attribute elimination.";  }  /**   * Returns a tip text for this property suitable for display in the   * GUI   *   * @return tip text string describing this property   */  public String percentToEliminatePerIterationTipText() {    return "Percent rate of attribute elimination.";  }  /**   * Returns a tip text for this property suitable for display in the   * GUI   *   * @return tip text string describing this property   */  public String percentThresholdTipText() {    return "Threshold below which percent elimination reverts to constant elimination.";  }  /**   * Returns a tip text for this property suitable for display in the   * GUI   *   * @return tip text string describing this property   */  public String epsilonParameterTipText() {    return "P epsilon parameter to pass to the SVM";  }  /**   * Returns a tip text for this property suitable for display in the   * GUI   *   * @return tip text string describing this property   */  public String toleranceParameterTipText() {    return "T tolerance parameter to pass to the SVM";

⌨️ 快捷键说明

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