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

📄 wavelet.java

📁 代码是一个分类器的实现,其中使用了部分weka的源代码。可以将项目导入eclipse运行
💻 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. *//* * Wavelet.java * Copyright (C) 2006 University of Waikato, Hamilton, New Zealand * */package weka.filters.unsupervised.attribute;import weka.core.Attribute;import weka.core.Capabilities;import weka.core.FastVector;import weka.core.Instance;import weka.core.Instances;import weka.core.Option;import weka.core.OptionHandler;import weka.core.SelectedTag;import weka.core.Tag;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.MultiFilter;import weka.filters.SimpleBatchFilter;import java.util.Enumeration;import java.util.Vector;/**  <!-- globalinfo-start --> * A filter for wavelet transformation.<br/> * <br/> * For more information see:<br/> * <br/> * Wikipedia (2004). Discrete wavelet transform.<br/> * <br/> * Kristian Sandberg (2000). The Haar wavelet transform. University of Colorado at Boulder, USA. * <p/> <!-- globalinfo-end --> * <!-- technical-bibtex-start --> * BibTeX: * <pre> * &#64;misc{Wikipedia2004, *    author = {Wikipedia}, *    title = {Discrete wavelet transform}, *    year = {2004}, *    HTTP = {http://en.wikipedia.org/wiki/Discrete_wavelet_transform} * } *  * &#64;misc{Sandberg2000, *    address = {University of Colorado at Boulder, USA}, *    author = {Kristian Sandberg}, *    institution = {Dept. of Applied Mathematics}, *    title = {The Haar wavelet transform}, *    year = {2000}, *    HTTP = {http://amath.colorado.edu/courses/5720/2000Spr/Labs/Haar/haar.html} * } * </pre> * <p/> <!-- technical-bibtex-end --> * <!-- options-start --> * Valid options are: <p/> *  * <pre> -D *  Turns on output of debugging information.</pre> *  * <pre> -A &lt;Haar&gt; *  The algorithm to use. *  (default: HAAR)</pre> *  * <pre> -P &lt;Zero&gt; *  The padding to use. *  (default: ZERO)</pre> *  * <pre> -F &lt;filter specification&gt; *  The filter to use as preprocessing step (classname and options). *  (default: MultiFilter with ReplaceMissingValues and Normalize)</pre> *  * <pre>  * Options specific to filter weka.filters.MultiFilter ('-F'): * </pre> *  * <pre> -D *  Turns on output of debugging information.</pre> *  * <pre> -F &lt;classname [options]&gt; *  A filter to apply (can be specified multiple times).</pre> *  <!-- options-end --> * * @author FracPete (fracpete at waikato dot ac dot nz) * @version $Revision: 1.2 $ */public class Wavelet  extends SimpleBatchFilter   implements TechnicalInformationHandler {  /** for serialization */  static final long serialVersionUID = -3335106965521265631L;  /** the type of algorithm: Haar wavelet */  public static final int ALGORITHM_HAAR = 0;  /** the types of algorithm */  public static final Tag[] TAGS_ALGORITHM = {    new Tag(ALGORITHM_HAAR, "Haar")  };  /** the type of padding: Zero padding */  public static final int PADDING_ZERO = 0;  /** the types of padding */  public static final Tag[] TAGS_PADDING = {    new Tag(PADDING_ZERO, "Zero")  };  /** an optional filter for preprocessing of the data */  protected Filter m_Filter = null;    /** the type of algorithm */  protected int m_Algorithm = ALGORITHM_HAAR;    /** the type of padding */  protected int m_Padding = PADDING_ZERO;    /**   * default constructor   */  public Wavelet() {    super();        m_Filter = new MultiFilter();    ((MultiFilter) m_Filter).setFilters(	new Filter[]{	    new weka.filters.unsupervised.attribute.ReplaceMissingValues(),	    new weka.filters.unsupervised.attribute.Normalize()	    });  }    /**   * Returns a string describing this classifier.   *   * @return      a description of the classifier suitable for   *              displaying in the explorer/experimenter gui   */  public String globalInfo() {    return         "A filter for wavelet transformation.\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;    TechnicalInformation 	additional;        result = new TechnicalInformation(Type.MISC);    result.setValue(Field.AUTHOR, "Wikipedia");    result.setValue(Field.YEAR, "2004");    result.setValue(Field.TITLE, "Discrete wavelet transform");    result.setValue(Field.HTTP, "http://en.wikipedia.org/wiki/Discrete_wavelet_transform");        additional = result.add(Type.MISC);    additional.setValue(Field.AUTHOR, "Kristian Sandberg");    additional.setValue(Field.YEAR, "2000");    additional.setValue(Field.TITLE, "The Haar wavelet transform");    additional.setValue(Field.INSTITUTION, "Dept. of Applied Mathematics");    additional.setValue(Field.ADDRESS, "University of Colorado at Boulder, USA");    additional.setValue(Field.HTTP, "http://amath.colorado.edu/courses/5720/2000Spr/Labs/Haar/haar.html");        return result;  }  /**   * Gets an enumeration describing the available options.   *   * @return an enumeration of all the available options.   */  public Enumeration listOptions() {    Vector		result;    Enumeration		enm;    String		param;    SelectedTag		tag;    int			i;    result = new Vector();    enm = super.listOptions();    while (enm.hasMoreElements())      result.addElement(enm.nextElement());    param = "";    for (i = 0; i < TAGS_ALGORITHM.length; i++) {      if (i > 0)	param += "|";      tag = new SelectedTag(TAGS_ALGORITHM[i].getID(), TAGS_ALGORITHM);      param += tag.getSelectedTag().getReadable();    }    result.addElement(new Option(	"\tThe algorithm to use.\n"	+ "\t(default: HAAR)",	"A", 1, "-A <" + param + ">"));    param = "";    for (i = 0; i < TAGS_PADDING.length; i++) {      if (i > 0)	param += "|";      tag = new SelectedTag(TAGS_PADDING[i].getID(), TAGS_PADDING);      param += tag.getSelectedTag().getReadable();    }    result.addElement(new Option(	"\tThe padding to use.\n"	+ "\t(default: ZERO)",	"P", 1, "-P <" + param + ">"));    result.addElement(new Option(	"\tThe filter to use as preprocessing step (classname and options).\n"	+ "\t(default: MultiFilter with ReplaceMissingValues and Normalize)",	"F", 1, "-F <filter specification>"));    if (getFilter() instanceof OptionHandler) {      result.addElement(new Option(	  "",	  "", 0, "\nOptions specific to filter "	  + getFilter().getClass().getName() + " ('-F'):"));            enm = ((OptionHandler) getFilter()).listOptions();      while (enm.hasMoreElements())	result.addElement(enm.nextElement());    }    return result.elements();  }  /**   * returns the options of the current setup   *   * @return      the current options   */  public String[] getOptions() {    int       i;    Vector    result;    String[]  options;    result = new Vector();    options = super.getOptions();    for (i = 0; i < options.length; i++)      result.add(options[i]);    result.add("-A");    result.add("" + getAlgorithm().getSelectedTag().getReadable());    result.add("-P");    result.add("" + getPadding().getSelectedTag().getReadable());    result.add("-F");    if (getFilter() instanceof OptionHandler)      result.add(	  getFilter().getClass().getName() 	+ " " 	+ Utils.joinOptions(((OptionHandler) getFilter()).getOptions()));    else      result.add(	  getFilter().getClass().getName());    return (String[]) result.toArray(new String[result.size()]);	    }  /**   * Parses the options for this object. <p/>   *   <!-- options-start -->   * Valid options are: <p/>   *    * <pre> -D   *  Turns on output of debugging information.</pre>   *    * <pre> -A &lt;Haar&gt;   *  The algorithm to use.   *  (default: HAAR)</pre>   *    * <pre> -P &lt;Zero&gt;   *  The padding to use.   *  (default: ZERO)</pre>   *    * <pre> -F &lt;filter specification&gt;   *  The filter to use as preprocessing step (classname and options).   *  (default: MultiFilter with ReplaceMissingValues and Normalize)</pre>   *    * <pre>    * Options specific to filter weka.filters.MultiFilter ('-F'):   * </pre>   *    * <pre> -D   *  Turns on output of debugging information.</pre>   *    * <pre> -F &lt;classname [options]&gt;   *  A filter to apply (can be specified multiple times).</pre>   *    <!-- options-end -->   *   * @param options	the options to use   * @throws Exception	if the option setting fails   */  public void setOptions(String[] options) throws Exception {    String	tmpStr;    String[]	tmpOptions;    Filter	filter;    super.setOptions(options);    tmpStr = Utils.getOption("A", options);    if (tmpStr.length() != 0)      setAlgorithm(new SelectedTag(tmpStr, TAGS_ALGORITHM));    else      setAlgorithm(new SelectedTag(ALGORITHM_HAAR, TAGS_ALGORITHM));    tmpStr = Utils.getOption("P", options);    if (tmpStr.length() != 0)      setPadding(new SelectedTag(tmpStr, TAGS_PADDING));    else      setPadding(new SelectedTag(PADDING_ZERO, TAGS_PADDING));    tmpStr     = Utils.getOption("F", options);    tmpOptions = Utils.splitOptions(tmpStr);

⌨️ 快捷键说明

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