public class MultiClassClassifier extends RandomizableSingleClassifierEnhancer implements OptionHandler, WeightedInstancesHandler
-M <num> Sets the method to use. Valid values are 0 (1-against-all), 1 (random codes), 2 (exhaustive code), and 3 (1-against-1). (default 0)
-R <num> Sets the multiplier when using random codes. (default 2.0)
-P Use pairwise coupling (only has an effect for 1-against1)
-L Use log loss decoding for random and exhaustive codes.
-S <num> Random number seed. (default 1)
-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.functions.Logistic)
Options specific to classifier weka.classifiers.functions.Logistic:
-D Turn on debugging output.
-R <ridge> Set the ridge in the log-likelihood.
-M <number> Set the maximum number of iterations (default -1, until convergence).
Modifier and Type | Field and Description |
---|---|
static int |
METHOD_1_AGAINST_1
1-against-1
|
static int |
METHOD_1_AGAINST_ALL
1-against-all
|
static int |
METHOD_ERROR_EXHAUSTIVE
exhaustive correction code
|
static int |
METHOD_ERROR_RANDOM
random correction code
|
static Tag[] |
TAGS_METHOD
The error correction modes
|
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
Constructor and Description |
---|
MultiClassClassifier()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances insts)
Builds the classifiers.
|
double[] |
distributionForInstance(Instance inst)
Returns the distribution for an instance.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getLogLossDecoding()
Whether log loss decoding is used for random or exhaustive codes.
|
SelectedTag |
getMethod()
Gets the method used.
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
double |
getRandomWidthFactor()
Gets the multiplier when generating random codes.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
getUsePairwiseCoupling()
Gets whether to use pairwise coupling with 1-vs-1
classification to improve probability estimates.
|
java.lang.String |
globalInfo() |
double[] |
individualPredictions(Instance inst)
Returns the individual predictions of the base classifiers
for an instance.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options
|
java.lang.String |
logLossDecodingTipText() |
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
java.lang.String |
methodTipText() |
static double[] |
pairwiseCoupling(double[][] n,
double[][] r)
Implements pairwise coupling.
|
java.lang.String |
randomWidthFactorTipText() |
void |
setLogLossDecoding(boolean newlogLossDecoding)
Sets whether log loss decoding is used for random or exhaustive codes.
|
void |
setMethod(SelectedTag newMethod)
Sets the method used.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setRandomWidthFactor(double newRandomWidthFactor)
Sets the multiplier when generating random codes.
|
void |
setUsePairwiseCoupling(boolean p)
Set whether to use pairwise coupling with 1-vs-1
classification to improve probability estimates.
|
java.lang.String |
toString()
Prints the classifiers.
|
java.lang.String |
usePairwiseCouplingTipText() |
getSeed, seedTipText, setSeed
classifierTipText, getClassifier, postExecution, preExecution, setClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public static final int METHOD_1_AGAINST_ALL
public static final int METHOD_ERROR_RANDOM
public static final int METHOD_ERROR_EXHAUSTIVE
public static final int METHOD_1_AGAINST_1
public static final Tag[] TAGS_METHOD
public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class SingleClassifierEnhancer
Capabilities
public void buildClassifier(Instances insts) throws java.lang.Exception
buildClassifier
in interface Classifier
insts
- the training data.java.lang.Exception
- if a classifier can't be builtpublic double[] individualPredictions(Instance inst) throws java.lang.Exception
inst
- the instance to get the prediction forjava.lang.Exception
- if the predictions can't be computed successfullypublic double[] distributionForInstance(Instance inst) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
inst
- the instance to get the distribution forjava.lang.Exception
- if the distribution can't be computed successfullypublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableSingleClassifierEnhancer
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-M <num> Sets the method to use. Valid values are 0 (1-against-all), 1 (random codes), 2 (exhaustive code), and 3 (1-against-1). (default 0)
-R <num> Sets the multiplier when using random codes. (default 2.0)
-P Use pairwise coupling (only has an effect for 1-against1)
-L Use log loss decoding for random and exhaustive codes.
-S <num> Random number seed. (default 1)
-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.functions.Logistic)
Options specific to classifier weka.classifiers.functions.Logistic:
-D Turn on debugging output.
-R <ridge> Set the ridge in the log-likelihood.
-M <number> Set the maximum number of iterations (default -1, until convergence).
setOptions
in interface OptionHandler
setOptions
in class RandomizableSingleClassifierEnhancer
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableSingleClassifierEnhancer
public java.lang.String globalInfo()
public java.lang.String logLossDecodingTipText()
public boolean getLogLossDecoding()
public void setLogLossDecoding(boolean newlogLossDecoding)
newlogLossDecoding
- true if log loss is to be usedpublic java.lang.String randomWidthFactorTipText()
public double getRandomWidthFactor()
public void setRandomWidthFactor(double newRandomWidthFactor)
newRandomWidthFactor
- the new width multiplierpublic java.lang.String methodTipText()
public SelectedTag getMethod()
public void setMethod(SelectedTag newMethod)
newMethod
- the new method.public void setUsePairwiseCoupling(boolean p)
p
- true if pairwise coupling is to be usedpublic boolean getUsePairwiseCoupling()
public java.lang.String usePairwiseCouplingTipText()
public static double[] pairwiseCoupling(double[][] n, double[][] r)
n
- the sum of weights used to train each modelr
- the probability estimate from each modelpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(java.lang.String[] argv)
argv
- the options