Package weka.classifiers.meta

# Class Vote

java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.MultipleClassifiersCombiner
weka.classifiers.RandomizableMultipleClassifiersCombiner
weka.classifiers.meta.Vote

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Classifier`, `Aggregateable<Classifier>`, `BatchPredictor`, `CapabilitiesHandler`, `CapabilitiesIgnorer`, `CommandlineRunnable`, `EnvironmentHandler`, `OptionHandler`, `Randomizable`, `RevisionHandler`, `TechnicalInformationHandler`, `WeightedInstancesHandler`

public class Vote extends RandomizableMultipleClassifiersCombiner implements TechnicalInformationHandler, EnvironmentHandler, Aggregateable<Classifier>, WeightedInstancesHandler
Class for combining classifiers. Different combinations of probability estimates for classification are available.
For more information see:
Ludmila I. Kuncheva (2004). Combining Pattern Classifiers: Methods and Algorithms. John Wiley and Sons, Inc..
J. Kittler, M. Hatef, Robert P.W. Duin, J. Matas (1998). On combining classifiers. IEEE Transactions on Pattern Analysis and Machine Intelligence. 20(3):226-239.
If a base classifier cannot handle instance weights, and the instance weights are not uniform, the data will be resampled with replacement based on the weights before being passed to that base classifier.

Valid options are:

     -P <path to serialized classifier>
      Full path to serialized classifier to include.
      May be specified multiple times to include
      multiple serialized classifiers. Note: it does
      not make sense to use pre-built classifiers in
      a cross-validation.

     -R <AVG|PROD|MAJ|MIN|MAX|MED>
      The combination rule to use
      (default: AVG)

     -print
      Print the individual models in the output

     -S <num>
      Random number seed.
      (default 1)

     -B <classifier specification>
      Full class name of classifier to include, followed
      by scheme options. May be specified multiple times.
      (default: "weka.classifiers.rules.ZeroR")

     -output-debug-info
      If set, classifier is run in debug mode and
      may output additional info to the console

     -do-not-check-capabilities
      If set, classifier capabilities are not checked before classifier is built
      (use with caution).

     Options specific to classifier weka.classifiers.rules.ZeroR:

     -output-debug-info
      If set, classifier is run in debug mode and
      may output additional info to the console

     -do-not-check-capabilities
      If set, classifier capabilities are not checked before classifier is built
      (use with caution).

BibTeX:

     @book{Kuncheva2004,
        author = {Ludmila I. Kuncheva},
        publisher = {John Wiley and Sons, Inc.},
        title = {Combining Pattern Classifiers: Methods and Algorithms},
        year = {2004}
     }

     @article{Kittler1998,
        author = {J. Kittler and M. Hatef and Robert P.W. Duin and J. Matas},
        journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
        number = {3},
        pages = {226-239},
        title = {On combining classifiers},
        volume = {20},
        year = {1998}
     }

Version:
  $Revision: 15480 $
Author:
  Alexander K. Seewald (alex@seewald.at), Eibe Frank (eibe@cs.waikato.ac.nz), Roberto Perdisci (roberto.perdisci@gmail.com)
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `AVERAGE_RULE`
  combination rule: Average of Probabilities
  `static final int`
  `MAJORITY_VOTING_RULE`
  combination rule: Majority Voting (only nominal classes)
  `static final int`
  `MAX_RULE`
  combination rule: Maximum Probability
  `static final int`
  `MEDIAN_RULE`
  combination rule: Median Probability (only numeric class)
  `static final int`
  `MIN_RULE`
  combination rule: Minimum Probability
  `static final int`
  `PRODUCT_RULE`
  combination rule: Product of Probabilities (only nominal classes)
  `static final Tag[]`
  `TAGS_RULES`
  combination rules

  ### Fields inherited from class weka.classifiers.AbstractClassifier

  `BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Vote()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addPreBuiltClassifier(Classifier c)`
  Add a prebuilt classifier to the list for use in the ensemble
  `Classifier`
  `aggregate(Classifier toAggregate)`
  Aggregate an object with this one
  `void`
  `buildClassifier(Instances data)`
  Builds all classifiers in the ensemble
  `double`
  `classifyInstance(Instance instance)`
  Classifies the given test instance.
  `String`
  `combinationRuleTipText()`
  Returns the tip text for this property
  `double[]`
  `distributionForInstance(Instance instance)`
  Classifies a given instance using the selected combination rule.
  `String`
  `doNotPrintModelsTipText()`
  Returns the tip text for this property
  `void`
  `finalizeAggregation()`
  Call to complete the aggregation process.
  `Capabilities`
  `getCapabilities()`
  Returns default capabilities of the classifier.
  `SelectedTag`
  `getCombinationRule()`
  Gets the combination rule used
  `boolean`
  `getDoNotPrintModels()`
  Get whether to print the individual ensemble models in the output
  `String[]`
  `getOptions()`
  Gets the current settings of Vote.
  `File[]`
  `getPreBuiltClassifiers()`
  Get the paths to pre-built serialized classifiers to load and include in the ensemble
  `String`
  `getRevision()`
  Returns the revision string.
  `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.
  `String`
  `globalInfo()`
  Returns a string describing classifier
  `Enumeration<Option>`
  `listOptions()`
  Returns an enumeration describing the available options.
  `static void`
  `main(String[] argv)`
  Main method for testing this class.
  `String`
  `preBuiltClassifiersTipText()`
  Returns the tip text for this property
  `void`
  `removePreBuiltClassifier(Classifier c)`
  Remove a prebuilt classifier from the list to use in the ensemble
  `void`
  `setCombinationRule(SelectedTag newRule)`
  Sets the combination rule to use.
  `void`
  `setDoNotPrintModels(boolean print)`
  Set whether to print the individual ensemble models in the output
  `void`
  `setEnvironment(Environment env)`
  Set environment variable values to substitute in the paths of serialized models to load
  `void`
  `setOptions(String[] options)`
  Parses a given list of options.
  `void`
  `setPreBuiltClassifiers(File[] preBuilt)`
  Set the paths to pre-built serialized classifiers to load and include in the ensemble
  `String`
  `toString()`
  Output a representation of this classifier

  ### Methods inherited from class weka.classifiers.RandomizableMultipleClassifiersCombiner

  `getSeed, seedTipText, setSeed`

  ### Methods inherited from class weka.classifiers.MultipleClassifiersCombiner

  `classifiersTipText, getClassifier, getClassifiers, postExecution, preExecution, setClassifiers`

  ### Methods inherited from class weka.classifiers.AbstractClassifier

  `batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### AVERAGE_RULE

    public static final int AVERAGE_RULE
    combination rule: Average of Probabilities
    See Also:
      - Constant Field Values

  - ### PRODUCT_RULE

    public static final int PRODUCT_RULE
    combination rule: Product of Probabilities (only nominal classes)
    See Also:
      - Constant Field Values

  - ### MAJORITY_VOTING_RULE

    public static final int MAJORITY_VOTING_RULE
    combination rule: Majority Voting (only nominal classes)
    See Also:
      - Constant Field Values

  - ### MIN_RULE

    public static final int MIN_RULE
    combination rule: Minimum Probability
    See Also:
      - Constant Field Values

  - ### MAX_RULE

    public static final int MAX_RULE
    combination rule: Maximum Probability
    See Also:
      - Constant Field Values

  - ### MEDIAN_RULE

    public static final int MEDIAN_RULE
    combination rule: Median Probability (only numeric class)
    See Also:
      - Constant Field Values

  - ### TAGS_RULES

    public static final Tag[] TAGS_RULES
    combination rules

- ## Constructor Details

  - ### Vote

    public Vote()

- ## Method Details

  - ### globalInfo

    public String globalInfo()
    Returns a string describing classifier
    Returns:
      a description suitable for displaying in the explorer/experimenter gui

  - ### listOptions

    public Enumeration<Option> listOptions()
    Returns an enumeration describing the available options.
    Specified by:
      `listOptions` in interface `OptionHandler`
    Overrides:
      `listOptions` in class `RandomizableMultipleClassifiersCombiner`
    Returns:
      an enumeration of all the available options.

  - ### getOptions

    public String[] getOptions()
    Gets the current settings of Vote.
    Specified by:
      `getOptions` in interface `OptionHandler`
    Overrides:
      `getOptions` in class `RandomizableMultipleClassifiersCombiner`
    Returns:
      an array of strings suitable for passing to setOptions()

  - ### setOptions

    public void setOptions(String[] options) throws Exception
    Parses a given list of options.

    Valid options are:

         -P <path to serialized classifier>
          Full path to serialized classifier to include.
          May be specified multiple times to include
          multiple serialized classifiers. Note: it does
          not make sense to use pre-built classifiers in
          a cross-validation.

         -R <AVG|PROD|MAJ|MIN|MAX|MED>
          The combination rule to use
          (default: AVG)

         -print
          Print the individual models in the output

         -S <num>
          Random number seed.
          (default 1)

         -B <classifier specification>
          Full class name of classifier to include, followed
          by scheme options. May be specified multiple times.
          (default: "weka.classifiers.rules.ZeroR")

         -output-debug-info
          If set, classifier is run in debug mode and
          may output additional info to the console

         -do-not-check-capabilities
          If set, classifier capabilities are not checked before classifier is built
          (use with caution).

         Options specific to classifier weka.classifiers.rules.ZeroR:

         -output-debug-info
          If set, classifier is run in debug mode and
          may output additional info to the console

         -do-not-check-capabilities
          If set, classifier capabilities are not checked before classifier is built
          (use with caution).

    Specified by:
      `setOptions` in interface `OptionHandler`
    Overrides:
      `setOptions` in class `RandomizableMultipleClassifiersCombiner`
    Parameters:
      `options` - the list of options as an array of strings
    Throws:
      `Exception` - if an option is not supported

  - ### 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:
      `getTechnicalInformation` in interface `TechnicalInformationHandler`
    Returns:
      the technical information about this class

  - ### getCapabilities

    public Capabilities getCapabilities()
    Returns default capabilities of the classifier.
    Specified by:
      `getCapabilities` in interface `CapabilitiesHandler`
    Specified by:
      `getCapabilities` in interface `Classifier`
    Overrides:
      `getCapabilities` in class `MultipleClassifiersCombiner`
    Returns:
      the capabilities of this classifier
    See Also:
      - `Capabilities`

  - ### buildClassifier

    public void buildClassifier(Instances data) throws Exception
    Builds all classifiers in the ensemble
    Specified by:
      `buildClassifier` in interface `Classifier`
    Parameters:
      `data` - the training data to be used for generating the ensemble.
    Throws:
      `Exception` - if the classifier could not be built successfully

  - ### addPreBuiltClassifier

    public void addPreBuiltClassifier(Classifier c)
    Add a prebuilt classifier to the list for use in the ensemble
    Parameters:
      `c` - a prebuilt Classifier to add.

  - ### removePreBuiltClassifier

    public void removePreBuiltClassifier(Classifier c)
    Remove a prebuilt classifier from the list to use in the ensemble
    Parameters:
      `c` - the classifier to remove

  - ### classifyInstance

    public double classifyInstance(Instance instance) throws Exception
    Classifies the given test instance.
    Specified by:
      `classifyInstance` in interface `Classifier`
    Overrides:
      `classifyInstance` in class `AbstractClassifier`
    Parameters:
      `instance` - the instance to be classified
    Returns:
      the predicted most likely class for the instance or Utils.missingValue() if no prediction is made
    Throws:
      `Exception` - if an error occurred during the prediction

  - ### distributionForInstance

    public double[] distributionForInstance(Instance instance) throws Exception
    Classifies a given instance using the selected combination rule.
    Specified by:
      `distributionForInstance` in interface `Classifier`
    Overrides:
      `distributionForInstance` in class `AbstractClassifier`
    Parameters:
      `instance` - the instance to be classified
    Returns:
      the distribution
    Throws:
      `Exception` - if instance could not be classified successfully

  - ### combinationRuleTipText

    public String combinationRuleTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getCombinationRule

    public SelectedTag getCombinationRule()
    Gets the combination rule used
    Returns:
      the combination rule used

  - ### setCombinationRule

    public void setCombinationRule(SelectedTag newRule)
    Sets the combination rule to use. Values other than
    Parameters:
      `newRule` - the combination rule method to use

  - ### preBuiltClassifiersTipText

    public String preBuiltClassifiersTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### setPreBuiltClassifiers

    public void setPreBuiltClassifiers(File[] preBuilt)
    Set the paths to pre-built serialized classifiers to load and include in the ensemble
    Parameters:
      `preBuilt` - an array of File paths to serialized models

  - ### getPreBuiltClassifiers

    public File[] getPreBuiltClassifiers()
    Get the paths to pre-built serialized classifiers to load and include in the ensemble
    Returns:
      an array of File paths to serialized models

  - ### doNotPrintModelsTipText

    public String doNotPrintModelsTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### setDoNotPrintModels

    public void setDoNotPrintModels(boolean print)
    Set whether to print the individual ensemble models in the output
    Parameters:
      `print` - true if the individual models are to be printed

  - ### getDoNotPrintModels

    public boolean getDoNotPrintModels()
    Get whether to print the individual ensemble models in the output
    Returns:
      true if the individual models are to be printed

  - ### toString

    public String toString()
    Output a representation of this classifier
    Overrides:
      `toString` in class `Object`
    Returns:
      a string representation of the classifier

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Overrides:
      `getRevision` in class `AbstractClassifier`
    Returns:
      the revision

  - ### setEnvironment

    public void setEnvironment(Environment env)
    Set environment variable values to substitute in the paths of serialized models to load
    Specified by:
      `setEnvironment` in interface `EnvironmentHandler`
    Parameters:
      `env` - the environment variables to use

  - ### aggregate

    public Classifier aggregate(Classifier toAggregate) throws Exception
    Aggregate an object with this one
    Specified by:
      `aggregate` in interface `Aggregateable<Classifier>`
    Parameters:
      `toAggregate` - the object to aggregate
    Returns:
      the result of aggregation
    Throws:
      `Exception` - if the supplied object can't be aggregated for some reason

  - ### finalizeAggregation

    public void finalizeAggregation() throws Exception
    Call to complete the aggregation process. Allows implementers to do any final processing based on how many objects were aggregated.
    Specified by:
      `finalizeAggregation` in interface `Aggregateable<Classifier>`
    Throws:
      `Exception` - if the aggregation can't be finalized for some reason

  - ### main

    public static void main(String[] argv)
    Main method for testing this class.
    Parameters:
      `argv` - should contain the following arguments: -t training file [-T test file] [-c class index]