📄 dagging.java
字号:
/* * 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. *//* * Dagging.java * Copyright (C) 2005 University of Waikato, Hamilton, New Zealand * */package weka.classifiers.meta;import weka.classifiers.Classifier;import weka.classifiers.RandomizableSingleClassifierEnhancer;import weka.core.Instance;import weka.core.Instances;import weka.core.Option;import weka.core.TechnicalInformation;import weka.core.TechnicalInformationHandler;import weka.core.Utils;import weka.core.TechnicalInformation.Field;import weka.core.TechnicalInformation.Type;import java.util.Enumeration;import java.util.Vector;/** <!-- globalinfo-start --> * This meta classifier creates a number of disjoint, stratified folds out of the data and feeds each chunk of data to a copy of the supplied base classifier. Predictions are made via majority vote, since all the generated base classifiers are put into the Vote meta classifier. <br/> * Useful for base classifiers that are quadratic or worse in time behavior, regarding number of instances in the training data. <br/> * <br/> * For more information, see: <br/> * Ting, K. M., Witten, I. H.: Stacking Bagged and Dagged Models. In: Fourteenth international Conference on Machine Learning, San Francisco, CA, 367-375, 1997. * <p/> <!-- globalinfo-end --> * <!-- technical-bibtex-start --> * BibTeX: * <pre> * @inproceedings{Ting1997, * address = {San Francisco, CA}, * author = {Ting, K. M. and Witten, I. H.}, * booktitle = {Fourteenth international Conference on Machine Learning}, * editor = {D. H. Fisher}, * pages = {367-375}, * publisher = {Morgan Kaufmann Publishers}, * title = {Stacking Bagged and Dagged Models}, * year = {1997} * } * </pre> * <p/> <!-- technical-bibtex-end --> * <!-- options-start --> * Valid options are: <p/> * * <pre> -F <folds> * The number of folds for splitting the training set into * smaller chunks for the base classifier. * (default 10)</pre> * * <pre> -verbose * Whether to print some more information during building the * classifier. * (default is off)</pre> * * <pre> -S <num> * Random number seed. * (default 1)</pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <pre> -W * Full name of base classifier. * (default: weka.classifiers.functions.SMO)</pre> * * <pre> * Options specific to classifier weka.classifiers.functions.SMO: * </pre> * * <pre> -D * If set, classifier is run in debug mode and * may output additional info to the console</pre> * * <pre> -no-checks * Turns off all checks - use with caution! * Turning them off assumes that data is purely numeric, doesn't * contain any missing values, and has a nominal class. Turning them * off also means that no header information will be stored if the * machine is linear. Finally, it also assumes that no instance has * a weight equal to 0. * (default: checks on)</pre> * * <pre> -C <double> * The complexity constant C. (default 1)</pre> * * <pre> -N * Whether to 0=normalize/1=standardize/2=neither. (default 0=normalize)</pre> * * <pre> -L <double> * The tolerance parameter. (default 1.0e-3)</pre> * * <pre> -P <double> * The epsilon for round-off error. (default 1.0e-12)</pre> * * <pre> -M * Fit logistic models to SVM outputs. </pre> * * <pre> -V <double> * The number of folds for the internal * cross-validation. (default -1, use training data)</pre> * * <pre> -W <double> * The random number seed. (default 1)</pre> * * <pre> -K <classname and parameters> * The Kernel to use. * (default: weka.classifiers.functions.supportVector.PolyKernel)</pre> * * <pre> * Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel: * </pre> * * <pre> -D * Enables debugging output (if available) to be printed. * (default: off)</pre> * * <pre> -no-checks * Turns off all checks - use with caution! * (default: checks on)</pre> * * <pre> -C <num> * The size of the cache (a prime number). * (default: 250007)</pre> * * <pre> -E <num> * The Exponent to use. * (default: 1.0)</pre> * * <pre> -L * Use lower-order terms. * (default: no)</pre> * <!-- options-end --> * * Options after -- are passed to the designated classifier.<p/> * * @author Bernhard Pfahringer (bernhard at cs dot waikato dot ac dot nz) * @author FracPete (fracpete at waikato dot ac dot nz) * @version $Revision: 1.5 $ * @see Vote */public class Dagging extends RandomizableSingleClassifierEnhancer implements TechnicalInformationHandler { /** for serialization */ static final long serialVersionUID = 4560165876570074309L; /** the number of folds to use to split the training data */ protected int m_NumFolds = 10; /** the classifier used for voting */ protected Vote m_Vote = null; /** whether to output some progress information during building */ protected boolean m_Verbose = false; /** * Returns a string describing classifier * @return a description suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "This meta classifier creates a number of disjoint, stratified folds out " + "of the data and feeds each chunk of data to a copy of the supplied " + "base classifier. Predictions are made via majority vote, since all the " + "generated base classifiers are put into the Vote meta classifier. \n" + "Useful for base classifiers that are quadratic or worse in time " + "behavior, regarding number of instances in the training data. \n" + "\n" + "For more information, see: \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.INPROCEEDINGS); result.setValue(Field.AUTHOR, "Ting, K. M. and Witten, I. H."); result.setValue(Field.TITLE, "Stacking Bagged and Dagged Models"); result.setValue(Field.BOOKTITLE, "Fourteenth international Conference on Machine Learning"); result.setValue(Field.EDITOR, "D. H. Fisher"); result.setValue(Field.YEAR, "1997"); result.setValue(Field.PAGES, "367-375"); result.setValue(Field.PUBLISHER, "Morgan Kaufmann Publishers"); result.setValue(Field.ADDRESS, "San Francisco, CA"); return result; } /** * Constructor. */ public Dagging() { m_Classifier = new weka.classifiers.functions.SMO(); } /** * String describing default classifier. * * @return the default classifier classname */ protected String defaultClassifierString() { return weka.classifiers.functions.SMO.class.getName(); } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions() { Vector result = new Vector(); result.addElement(new Option( "\tThe number of folds for splitting the training set into\n" + "\tsmaller chunks for the base classifier.\n" + "\t(default 10)", "F", 1, "-F <folds>")); result.addElement(new Option( "\tWhether to print some more information during building the\n" + "\tclassifier.\n" + "\t(default is off)", "verbose", 0, "-verbose")); Enumeration en = super.listOptions(); while (en.hasMoreElements()) result.addElement(en.nextElement()); return result.elements(); } /** * Parses a given list of options. <p/> * <!-- options-start --> * Valid options are: <p/> * * <pre> -F <folds> * The number of folds for splitting the training set into * smaller chunks for the base classifier. * (default 10)</pre> * * <pre> -verbose * Whether to print some more information during building the * classifier. * (default is off)</pre> * * <pre> -S <num>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -