Package weka.classifiers.functions
Class VotedPerceptron
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.functions.VotedPerceptron
-
- All Implemented Interfaces:
Serializable,Cloneable,Classifier,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,RevisionHandler,TechnicalInformationHandler
public class VotedPerceptron extends AbstractClassifier implements OptionHandler, TechnicalInformationHandler
Implementation of the voted perceptron algorithm by Freund and Schapire. Globally replaces all missing values, and transforms nominal attributes into binary ones.
For more information, see:
Y. Freund, R. E. Schapire: Large margin classification using the perceptron algorithm. In: 11th Annual Conference on Computational Learning Theory, New York, NY, 209-217, 1998. BibTeX:@inproceedings{Freund1998, address = {New York, NY}, author = {Y. Freund and R. E. Schapire}, booktitle = {11th Annual Conference on Computational Learning Theory}, pages = {209-217}, publisher = {ACM Press}, title = {Large margin classification using the perceptron algorithm}, year = {1998} }Valid options are:-I <int> The number of iterations to be performed. (default 1)
-E <double> The exponent for the polynomial kernel. (default 1)
-S <int> The seed for the random number generation. (default 1)
-M <int> The maximum number of alterations allowed. (default 10000)
- Version:
- $Revision$
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description VotedPerceptron()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(Instances insts)Builds the ensemble of perceptrons.double[]distributionForInstance(Instance inst)Outputs the distribution for the given output.StringexponentTipText()Returns the tip text for this propertyCapabilitiesgetCapabilities()Returns default capabilities of the classifier.doublegetExponent()Get the value of exponent.intgetMaxK()Get the value of maxK.intgetNumIterations()Get the value of NumIterations.String[]getOptions()Gets the current settings of the classifier.StringgetRevision()Returns the revision string.intgetSeed()Get the value of Seed.TechnicalInformationgetTechnicalInformation()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.StringglobalInfo()Returns a string describing this classifierEnumeration<Option>listOptions()Returns an enumeration describing the available options.static voidmain(String[] argv)Main method.StringmaxKTipText()Returns the tip text for this propertyStringnumIterationsTipText()Returns the tip text for this propertyStringseedTipText()Returns the tip text for this propertyvoidsetExponent(double v)Set the value of exponent.voidsetMaxK(int v)Set the value of maxK.voidsetNumIterations(int v)Set the value of NumIterations.voidsetOptions(String[] options)Parses a given list of options.voidsetSeed(int v)Set the value of Seed.StringtoString()Returns textual description of classifier.-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public TechnicalInformation getTechnicalInformation()
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.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
listOptions
public Enumeration<Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classAbstractClassifier- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
Parses a given list of options. Valid options are:-I <int> The number of iterations to be performed. (default 1)
-E <double> The exponent for the polynomial kernel. (default 1)
-S <int> The seed for the random number generation. (default 1)
-M <int> The maximum number of alterations allowed. (default 10000)
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classAbstractClassifier- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
public String[] getOptions()
Gets the current settings of the classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classAbstractClassifier- Returns:
- an array of strings suitable for passing to setOptions
-
getCapabilities
public Capabilities getCapabilities()
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClassifier- Overrides:
getCapabilitiesin classAbstractClassifier- Returns:
- the capabilities of this classifier
- See Also:
Capabilities
-
buildClassifier
public void buildClassifier(Instances insts) throws Exception
Builds the ensemble of perceptrons.- Specified by:
buildClassifierin interfaceClassifier- Parameters:
insts- the data to train the classifier with- Throws:
Exception- if something goes wrong during building
-
distributionForInstance
public double[] distributionForInstance(Instance inst) throws Exception
Outputs the distribution for the given output. Pipes output of SVM through sigmoid function.- Specified by:
distributionForInstancein interfaceClassifier- Overrides:
distributionForInstancein classAbstractClassifier- Parameters:
inst- the instance for which distribution is to be computed- Returns:
- the distribution
- Throws:
Exception- if something goes wrong
-
toString
public String toString()
Returns textual description of classifier.
-
maxKTipText
public String maxKTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMaxK
public int getMaxK()
Get the value of maxK.- Returns:
- Value of maxK.
-
setMaxK
public void setMaxK(int v)
Set the value of maxK.- Parameters:
v- Value to assign to maxK.
-
numIterationsTipText
public String numIterationsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumIterations
public int getNumIterations()
Get the value of NumIterations.- Returns:
- Value of NumIterations.
-
setNumIterations
public void setNumIterations(int v)
Set the value of NumIterations.- Parameters:
v- Value to assign to NumIterations.
-
exponentTipText
public String exponentTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getExponent
public double getExponent()
Get the value of exponent.- Returns:
- Value of exponent.
-
setExponent
public void setExponent(double v)
Set the value of exponent.- Parameters:
v- Value to assign to exponent.
-
seedTipText
public String seedTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSeed
public int getSeed()
Get the value of Seed.- Returns:
- Value of Seed.
-
setSeed
public void setSeed(int v)
Set the value of Seed.- Parameters:
v- Value to assign to Seed.
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
main
public static void main(String[] argv)
Main method.- Parameters:
argv- the commandline options
-
-