Package weka.classifiers.meta
Class Consensus
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.MultipleClassifiersCombiner
-
- weka.classifiers.meta.Consensus
-
- 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.RevisionHandler
public class Consensus extends weka.classifiers.MultipleClassifiersCombiner implements AbstainingClassifier
Outputs predictions only if the ensemble agrees. In case of agreement, the classifier identified by the 'predictor' index is used for making the actual prediction.
Valid options are:-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).
-predictor <1-based index> The index of the classifier for making the actual predictions. (default: 1)
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.core.Index
m_Predictor
the index of the classifier to use for making the actual prediction.
-
Constructor Summary
Constructors Constructor Description Consensus()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Generates a classifier.boolean
canAbstain()
Whether abstaining is possible, e.g., used in meta-classifiers.double
classifyInstance(weka.core.Instance instance)
Classifies the given test instance.protected boolean
consensus(weka.core.Instance instance)
Checks whether there is consensus between the classifiers.double[]
distributionForInstance(weka.core.Instance instance)
Predicts the class memberships for a given instance.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.String[]
getOptions()
Gets the current settings of Vote.adams.core.Index
getPredictor()
Returns the index of the classifier for making the actual predictions.String
globalInfo()
Returns a string describing classifierEnumeration
listOptions()
Returns an enumeration describing the available options.String
predictorTipText()
Returns the tip text for this property.void
setOptions(String[] options)
Parses a given list of options.void
setPredictor(adams.core.Index value)
Sets the index of the classifier for making the actual predictions.-
Methods inherited from class weka.classifiers.MultipleClassifiersCombiner
classifiersTipText, getCapabilities, 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
-
-
-
-
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.MultipleClassifiersCombiner
- 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.MultipleClassifiersCombiner
- Returns:
- an array of strings suitable for passing to setOptions()
-
setOptions
public void setOptions(String[] options) throws Exception
Parses a given list of options.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.MultipleClassifiersCombiner
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
setPredictor
public void setPredictor(adams.core.Index value)
Sets the index of the classifier for making the actual predictions.- Parameters:
value
- the index (1-based)
-
getPredictor
public adams.core.Index getPredictor()
Returns the index of the classifier for making the actual predictions.- Returns:
- the index (1-based)
-
predictorTipText
public String predictorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Generates a classifier.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Parameters:
data
- set of instances serving as training data- Throws:
Exception
- if the classifier has not been generated successfully
-
consensus
protected boolean consensus(weka.core.Instance instance) throws Exception
Checks whether there is consensus between the classifiers.- Parameters:
instance
- the instance to check- Returns:
- true if consensus
- Throws:
Exception
- if classification fails
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws Exception
Classifies the given test instance. The instance has to belong to a dataset when it's being classified.- 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 Utils.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
Predicts 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:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in 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
- Throws:
Exception
- if distribution could not be computed successfully
-
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
-
-