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.Indexm_Predictorthe 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 voidbuildClassifier(weka.core.Instances data)Generates a classifier.booleancanAbstain()Whether abstaining is possible, e.g., used in meta-classifiers.doubleclassifyInstance(weka.core.Instance instance)Classifies the given test instance.protected booleanconsensus(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.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.String[]getOptions()Gets the current settings of Vote.adams.core.IndexgetPredictor()Returns the index of the classifier for making the actual predictions.StringglobalInfo()Returns a string describing classifierEnumerationlistOptions()Returns an enumeration describing the available options.StringpredictorTipText()Returns the tip text for this property.voidsetOptions(String[] options)Parses a given list of options.voidsetPredictor(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:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.classifiers.MultipleClassifiersCombiner- Returns:
- an enumeration of all the available options.
-
getOptions
public String[] getOptions()
Gets the current settings of Vote.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin 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:
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
-
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 ExceptionGenerates a classifier.- Specified by:
buildClassifierin 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 ExceptionChecks 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 ExceptionClassifies the given test instance. The instance has to belong to a dataset when it's being classified.- Specified by:
classifyInstancein interfaceweka.classifiers.Classifier- Overrides:
classifyInstancein 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 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
- 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:
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
-
-