Package weka.classifiers.meta
Class ConsensusOrVote
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.MultipleClassifiersCombiner
-
- weka.classifiers.meta.ConsensusOrVote
-
- All Implemented Interfaces:
Serializable,Cloneable,AbstainingClassifier,weka.classifiers.Classifier,weka.core.BatchPredictor,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,ModelOutputHandler,weka.core.OptionHandler,weka.core.RevisionHandler
public class ConsensusOrVote extends weka.classifiers.MultipleClassifiersCombiner implements ModelOutputHandler, AbstainingClassifier
If the required minimum number of classifiers of the ensemble agree on a label, then this label is predicted. Otherwise, Vote with majority rule is used.
Valid options are:-support <value> The percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it (default: 1.0)
-suppress-model-output If enabled, suppresses any large model output.
-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).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
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).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_ActualSupportthe actual number of classifiers that need to support the label.protected doublem_Supportthe percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.protected booleanm_SuppressModelOutputwhether to suppress the model output.protected weka.classifiers.meta.Votem_Votethe ensemble.static StringSUPPORTstatic StringSUPPRESS_MODEL_OUTPUT
-
Constructor Summary
Constructors Constructor Description ConsensusOrVote()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(weka.core.Instances data)Builds the ensemble.booleancanAbstain()Whether abstaining is possible, e.g., used in meta-classifiers.doubleclassifyInstance(weka.core.Instance instance)Predicts the class label index for the given instance.double[]distributionForInstance(weka.core.Instance instance)Predicts the class memberships for a given instance.doublegetAbstentionClassification(weka.core.Instance inst)The prediction that made the classifier abstain.double[]getAbstentionDistribution(weka.core.Instance inst)The class distribution that made the classifier abstain.weka.core.CapabilitiesgetCapabilities()Returns the ensemble's capabilities.protected doublegetDefaultSupport()Returns the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.String[]getOptions()Gets the current option settings for the OptionHandler.doublegetSupport()Returns the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.booleangetSuppressModelOutput()Returns whether to output the model with the toString() method or not.StringglobalInfo()Returns a string describing classifierprotected booleanisAbstaining(weka.core.Instance instance)Determines whether to abstain from the prediction.EnumerationlistOptions()Returns an enumeration describing the available options.voidsetOptions(String[] options)Sets the OptionHandler's options using the given list.voidsetSupport(double value)Sets the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.voidsetSuppressModelOutput(boolean value)Sets whether to output the model with the toString() method or not.StringsupportTipText()Returns the tip text for this property.StringsuppressModelOutputTipText()Returns the tip text for this property.StringtoString()Outputs the ensemble model.-
Methods inherited from class weka.classifiers.MultipleClassifiersCombiner
classifiersTipText, getClassifier, getClassifiers, getClassifierSpec, postExecution, preExecution, setClassifiers
-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
SUPPORT
public static final String SUPPORT
- See Also:
- Constant Field Values
-
SUPPRESS_MODEL_OUTPUT
public static final String SUPPRESS_MODEL_OUTPUT
- See Also:
- Constant Field Values
-
m_Support
protected double m_Support
the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.
-
m_ActualSupport
protected int m_ActualSupport
the actual number of classifiers that need to support the label.
-
m_Vote
protected weka.classifiers.meta.Vote m_Vote
the ensemble.
-
m_SuppressModelOutput
protected boolean m_SuppressModelOutput
whether to suppress the model output.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the gui
-
getDefaultSupport
protected double getDefaultSupport()
Returns the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.- Returns:
- the default
-
setSupport
public void setSupport(double value)
Sets the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.- Parameters:
value- the support
-
getSupport
public double getSupport()
Returns the percentage (0-1 excl) or number of base-classifiers (>= 1) that need to chose the label in order to predict it.- Returns:
- the support
-
supportTipText
public String supportTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setSuppressModelOutput
public void setSuppressModelOutput(boolean value)
Sets whether to output the model with the toString() method or not.- Specified by:
setSuppressModelOutputin interfaceModelOutputHandler- Parameters:
value- true if to suppress model output
-
getSuppressModelOutput
public boolean getSuppressModelOutput()
Returns whether to output the model with the toString() method or not.- Specified by:
getSuppressModelOutputin interfaceModelOutputHandler- Returns:
- the label index
-
suppressModelOutputTipText
public String suppressModelOutputTipText()
Returns the tip text for this property.- Specified by:
suppressModelOutputTipTextin interfaceModelOutputHandler- Returns:
- tip text for this property suitable for displaying in the gui
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.classifiers.MultipleClassifiersCombiner- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
Sets the OptionHandler's options using the given list. All options will be set (or reset) during this call (i.e. incremental setting of options is not possible).- Specified by:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classweka.classifiers.MultipleClassifiersCombiner- 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 option settings for the OptionHandler.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.classifiers.MultipleClassifiersCombiner- Returns:
- the list of current option settings as an array of strings
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns the ensemble's capabilities.- Specified by:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Specified by:
getCapabilitiesin interfaceweka.classifiers.Classifier- Overrides:
getCapabilitiesin classweka.classifiers.MultipleClassifiersCombiner- Returns:
- the capabilities
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws ExceptionBuilds the ensemble.- Specified by:
buildClassifierin interfaceweka.classifiers.Classifier- Parameters:
data- the training data- Throws:
Exception- if training fails
-
isAbstaining
protected boolean isAbstaining(weka.core.Instance instance) throws ExceptionDetermines whether to abstain from the prediction.- Parameters:
instance- the instance to make the prediction for- Returns:
- true if to abstain
- Throws:
Exception- if prediction fails
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws ExceptionPredicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value.- Specified by:
distributionForInstancein interfaceweka.classifiers.Classifier- Overrides:
distributionForInstancein classweka.classifiers.AbstractClassifier- Parameters:
instance- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction, zeroed array if abstained
- Throws:
Exception- if distribution could not be computed successfully
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws ExceptionPredicts the class label index for the given instance.- Specified by:
classifyInstancein interfaceweka.classifiers.Classifier- Overrides:
classifyInstancein classweka.classifiers.AbstractClassifier- Parameters:
instance- the instance to make the prediction for- Returns:
- the class label index, missing value if abstained
- Throws:
Exception- if prediction fails
-
canAbstain
public boolean canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.- Specified by:
canAbstainin interfaceAbstainingClassifier- Returns:
- true if abstaining is possible
-
getAbstentionClassification
public double getAbstentionClassification(weka.core.Instance inst) throws ExceptionThe prediction that made the classifier abstain.- Specified by:
getAbstentionClassificationin interfaceAbstainingClassifier- Parameters:
inst- the instance to get the prediction for- Returns:
- the prediction
- Throws:
Exception- if fails to make prediction
-
getAbstentionDistribution
public double[] getAbstentionDistribution(weka.core.Instance inst) throws ExceptionThe class distribution that made the classifier abstain.- Specified by:
getAbstentionDistributionin interfaceAbstainingClassifier- Parameters:
inst- the instance to get the prediction for- Returns:
- the class distribution
- Throws:
Exception- if fails to make prediction
-
-