Package weka.classifiers.meta
Class AbstainingClassifierWrapper
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.SingleClassifierEnhancer
-
- weka.classifiers.meta.AbstainingClassifierWrapper
-
- All Implemented Interfaces:
Serializable
,Cloneable
,AbstainingClassifier
,weka.classifiers.Classifier
,ThreadSafeClassifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
public class AbstainingClassifierWrapper extends weka.classifiers.SingleClassifierEnhancer implements AbstainingClassifier, ThreadSafeClassifier
Wraps an abstaining classifier and allows turning on/of abstaining. Valid options are:-turn-off-abstaining <value> If enabled, abstaining of the base classifier is turned off. (default: false)
-W Full name of base classifier. (default: weka.classifiers.meta.AbstainMinimumProbability)
-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.meta.AbstainMinimumProbability:
-W Full name of base classifier. (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).
-min-probability <value> The minimum probability that the chosen label must meet. (default: 0.8)
- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_CanAbstain
whether the base classifier can abstain.protected boolean
m_TurnOffAbstaining
whether to turn off abstaining.static String
TURN_OFF_ABSTAINING
-
Constructor Summary
Constructors Constructor Description AbstainingClassifierWrapper()
Initializes the classifier.
-
Method Summary
All Methods Static 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)
Synchronized call of super method for making classification.protected String
defaultClassifierString()
String describing default classifier.double[]
distributionForInstance(weka.core.Instance instance)
Returns the class distribution for an 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 option settings for the OptionHandler.boolean
getTurnOffAbstaining()
Returns whether abstaining of the base classifier is turned off.String
globalInfo()
Returns a string describing classifier.Enumeration
listOptions()
Returns an enumeration describing the available options.static void
main(String[] args)
Main method for running this class.void
setClassifier(weka.classifiers.Classifier value)
Set the base learner.void
setOptions(String[] options)
Sets the OptionHandler's options using the given list.void
setTurnOffAbstaining(boolean value)
Sets whether to turn off abstaining of the base classifier.String
toString()
Returns the model.String
turnOffAbstainingTipText()
Returns the tip text for this property-
Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, defaultClassifierOptions, getCapabilities, getClassifier, getClassifierSpec, postExecution, preExecution
-
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
-
TURN_OFF_ABSTAINING
public static final String TURN_OFF_ABSTAINING
- See Also:
- Constant Field Values
-
m_TurnOffAbstaining
protected boolean m_TurnOffAbstaining
whether to turn off abstaining.
-
m_CanAbstain
protected boolean m_CanAbstain
whether the base classifier can abstain.
-
-
Method Detail
-
defaultClassifierString
protected String defaultClassifierString()
String describing default classifier.- Overrides:
defaultClassifierString
in classweka.classifiers.SingleClassifierEnhancer
-
globalInfo
public String globalInfo()
Returns a string describing classifier.- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
setClassifier
public void setClassifier(weka.classifiers.Classifier value)
Set the base learner.- Overrides:
setClassifier
in classweka.classifiers.SingleClassifierEnhancer
- Parameters:
value
- the classifier to use.
-
setTurnOffAbstaining
public void setTurnOffAbstaining(boolean value)
Sets whether to turn off abstaining of the base classifier.- Parameters:
value
- true if to turn off abstaining
-
getTurnOffAbstaining
public boolean getTurnOffAbstaining()
Returns whether abstaining of the base classifier is turned off.- Returns:
- value true if abstaining is turned off
-
turnOffAbstainingTipText
public String turnOffAbstainingTipText()
Returns the tip text for this property- Returns:
- tip text for this property 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.SingleClassifierEnhancer
- 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:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.SingleClassifierEnhancer
- 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:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.SingleClassifierEnhancer
- Returns:
- the list of current option settings as an array of strings
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.- 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
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws Exception
Synchronized call of super method for making classification.- Specified by:
classifyInstance
in interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to classify- Returns:
- the classification
- Throws:
Exception
- if classification fails
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Returns the class distribution for an instance.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to get the distribution for- Returns:
- the distribution
- Throws:
Exception
- if classification fails
-
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
-
toString
public String toString()
Returns the model.
-
main
public static void main(String[] args)
Main method for running this class.- Parameters:
args
- the options
-
-