Package weka.classifiers.meta
Class AbstainVote
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.MultipleClassifiersCombiner
-
- weka.classifiers.RandomizableMultipleClassifiersCombiner
-
- weka.classifiers.meta.AbstainVote
-
- All Implemented Interfaces:
Serializable
,Cloneable
,AbstainingClassifier
,weka.classifiers.Classifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.Randomizable
,weka.core.RevisionHandler
,weka.core.WeightedInstancesHandler
public class AbstainVote extends weka.classifiers.RandomizableMultipleClassifiersCombiner implements weka.core.WeightedInstancesHandler, AbstainingClassifier
Finds the base classifier with the best least median squared error.
Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the console
-S <sint> Number of regressions (default: 10)
-P <int> Percent sample size (default: 60)
-E <int> Percent Error at (default: 50)
-G <seed> Set the seed used to generate samples (default: 0)
- Version:
- $Revision: 12763 $
- Author:
- Dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
AVERAGE_RULE
combination rule: Average of Probabilitiesprotected int
m_CombinationRule
Combination Rule variableprotected boolean[]
m_IsPercent
protected double
m_MaxDifference
protected double[]
m_MaxDifferences
protected String
m_MaxDifferences_string
protected double[]
m_Maxes
protected double[]
m_Mins
protected Random
m_Random
the random number generator used for breaking ties in majority votingstatic int
MAJORITY_VOTING_RULE
combination rule: Majority Voting (only nominal classes)static int
MAX_RULE
combination rule: Maximum Probabilitystatic int
MEDIAN_RULE
combination rule: Median Probability (only numeric class)static int
MIN_RULE
combination rule: Minimum Probabilitystatic int
PRODUCT_RULE
combination rule: Product of Probabilities (only nominal classes)static weka.core.Tag[]
TAGS_RULES
combination rules
-
Constructor Summary
Constructors Constructor Description AbstainVote()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data.boolean
canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.protected boolean
checkOK(double avgPrediction, double difference)
protected double
classificationNumericAverage(weka.core.Instance instance)
protected double
classificationNumericMedian(weka.core.Instance instance)
double
classifyInstance(weka.core.Instance instance)
Classifies the given test instance.protected double
classifyInstanceMedian(weka.core.Instance instance)
Classifies the given test instance, returning the median from all classifiers.String
combinationRuleTipText()
Returns the tip text for this propertyprotected String
diffToString()
double[]
distributionForInstance(weka.core.Instance instance)
Classifies a given instance using the selected combination rule.protected double[]
distributionForInstanceAverage(weka.core.Instance instance)
Classifies a given instance using the Average of Probabilities combination rule.protected double[]
distributionForInstanceMajorityVoting(weka.core.Instance instance)
Classifies a given instance using the Majority Voting combination rule.protected double[]
distributionForInstanceMax(weka.core.Instance instance)
Classifies a given instance using the Maximum Probability combination rule.protected double[]
distributionForInstanceMin(weka.core.Instance instance)
Classifies a given instance using the Minimum Probability combination rule.protected double[]
distributionForInstanceProduct(weka.core.Instance instance)
Classifies a given instance using the Product of Probabilities combination rule.double
getAbstentionClassification(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.Capabilities
getCapabilities()
Returns default capabilities of the classifier.weka.core.SelectedTag
getCombinationRule()
Gets the combination rule usedString
getMaxDifference()
gets number of samplesString[]
getOptions()
Gets the current settings of Vote.String
getRevision()
Returns the revision string.weka.core.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 classifierEnumeration
listOptions()
Returns an enumeration describing the available options.static void
main(String[] argv)
Main method for testing this class.String
maxDifferenceTipText()
Returns the tip text for this propertyprotected void
parseString(String input)
Expect ; separated entries with min,max,difference e.g.void
setCombinationRule(weka.core.SelectedTag newRule)
Sets the combination rule to use.void
setMaxDifference(String s)
void
setOptions(String[] options)
Parses a given list of options.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, getClassifierSpec, 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
-
-
-
-
Field Detail
-
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 weka.core.Tag[] TAGS_RULES
combination rules
-
m_CombinationRule
protected int m_CombinationRule
Combination Rule variable
-
m_Random
protected Random m_Random
the random number generator used for breaking ties in majority voting
-
m_MaxDifference
protected double m_MaxDifference
-
m_MaxDifferences
protected double[] m_MaxDifferences
-
m_Mins
protected double[] m_Mins
-
m_Maxes
protected double[] m_Maxes
-
m_IsPercent
protected boolean[] m_IsPercent
-
m_MaxDifferences_string
protected String m_MaxDifferences_string
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.RandomizableMultipleClassifiersCombiner
- Returns:
- an enumeration of all the available options.
-
getOptions
public String[] getOptions()
Gets the current settings of Vote.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.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:-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")
-D If set, classifier is run in debug mode and may output additional info to the console
-R <AVG|PROD|MAJ|MIN|MAX|MED> The combination rule to use (default: AVG)
- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.RandomizableMultipleClassifiersCombiner
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getTechnicalInformation
public weka.core.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.- Returns:
- the technical information about this class
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.MultipleClassifiersCombiner
- Returns:
- the capabilities of this classifier
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Parameters:
data
- the training data to be used for generating the boosted classifier.- Throws:
Exception
- if the classifier could not be built successfully
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws Exception
Classifies the given test instance.- Specified by:
classifyInstance
in interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
- Throws:
Exception
- if an error occurred during the prediction
-
classifyInstanceMedian
protected double classifyInstanceMedian(weka.core.Instance instance) throws Exception
Classifies the given test instance, returning the median from all classifiers.- Parameters:
instance
- the instance to be classified- Returns:
- the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
- Throws:
Exception
- if an error occurred during the prediction
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Classifies a given instance using the selected combination rule.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
classificationNumericMedian
protected double classificationNumericMedian(weka.core.Instance instance) throws Exception
- Throws:
Exception
-
checkOK
protected boolean checkOK(double avgPrediction, double difference)
-
parseString
protected void parseString(String input)
Expect ; separated entries with min,max,difference e.g. 0-50,6;50-100,10%;100-200,20- Parameters:
input
-
-
diffToString
protected String diffToString()
-
classificationNumericAverage
protected double classificationNumericAverage(weka.core.Instance instance) throws Exception
- Throws:
Exception
-
distributionForInstanceAverage
protected double[] distributionForInstanceAverage(weka.core.Instance instance) throws Exception
Classifies a given instance using the Average of Probabilities combination rule.- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
distributionForInstanceProduct
protected double[] distributionForInstanceProduct(weka.core.Instance instance) throws Exception
Classifies a given instance using the Product of Probabilities combination rule.- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
distributionForInstanceMajorityVoting
protected double[] distributionForInstanceMajorityVoting(weka.core.Instance instance) throws Exception
Classifies a given instance using the Majority Voting combination rule.- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
distributionForInstanceMax
protected double[] distributionForInstanceMax(weka.core.Instance instance) throws Exception
Classifies a given instance using the Maximum Probability combination rule.- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
distributionForInstanceMin
protected double[] distributionForInstanceMin(weka.core.Instance instance) throws Exception
Classifies a given instance using the Minimum Probability combination rule.- 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 weka.core.SelectedTag getCombinationRule()
Gets the combination rule used- Returns:
- the combination rule used
-
setCombinationRule
public void setCombinationRule(weka.core.SelectedTag newRule)
Sets the combination rule to use. Values other than- Parameters:
newRule
- the combination rule method to use
-
toString
public String toString()
Output a representation of this classifier
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.AbstractClassifier
- Returns:
- the revision
-
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]
-
canAbstain
public boolean canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.- Specified by:
canAbstain
in interfaceAbstainingClassifier
- Returns:
- true if abstaining is possible
-
getAbstentionClassification
public double getAbstentionClassification(weka.core.Instance inst) throws Exception
The prediction that made the classifier abstain.- Specified by:
getAbstentionClassification
in 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 Exception
The class distribution that made the classifier abstain.- Specified by:
getAbstentionDistribution
in interfaceAbstainingClassifier
- Parameters:
inst
- the instance to get the prediction for- Returns:
- the class distribution
- Throws:
Exception
- if fails to make prediction
-
maxDifferenceTipText
public String maxDifferenceTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMaxDifference
public String getMaxDifference()
gets number of samples- Returns:
- value
-
setMaxDifference
public void setMaxDifference(String s)
-
-