public class CostSensitiveClassifier extends RandomizableSingleClassifierEnhancer implements OptionHandler, Drawable, BatchPredictor, WeightedInstancesHandler
-M Minimize expected misclassification cost. Default is to reweight training instances according to costs per class
-C <cost file name> File name of a cost matrix to use. If this is not supplied, a cost matrix will be loaded on demand. The name of the on-demand file is the relation name of the training data plus ".cost", and the path to the on-demand file is specified with the -N option.
-N <directory> Name of a directory to search for cost files when loading costs on demand (default current directory).
-cost-matrix <matrix> The cost matrix in Matlab single line format.
-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.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 consoleOptions after -- are passed to the designated classifier.
| Modifier and Type | Field and Description |
|---|---|
static int |
MATRIX_ON_DEMAND
load cost matrix on demand
|
static int |
MATRIX_SUPPLIED
use explicit cost matrix
|
static Tag[] |
TAGS_MATRIX_SOURCE
Specify possible sources of the cost matrix
|
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULTBayesNet, Newick, NOT_DRAWABLE, TREE| Constructor and Description |
|---|
CostSensitiveClassifier()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
batchSizeTipText()
Tool tip text for this property
|
void |
buildClassifier(Instances data)
Builds the model of the base learner.
|
java.lang.String |
costMatrixSourceTipText() |
java.lang.String |
costMatrixTipText() |
double[] |
distributionForInstance(Instance instance)
Returns class probabilities.
|
double[][] |
distributionsForInstances(Instances insts)
Batch scoring method.
|
java.lang.String |
getBatchSize()
Gets the preferred batch size from the base learner if it implements
BatchPredictor.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
CostMatrix |
getCostMatrix()
Gets the misclassification cost matrix.
|
SelectedTag |
getCostMatrixSource()
Gets the source location method of the cost matrix.
|
boolean |
getMinimizeExpectedCost()
Gets the value of MinimizeExpectedCost.
|
java.io.File |
getOnDemandDirectory()
Returns the directory that will be searched for cost files when
loading on demand.
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
java.lang.String |
getRevision()
Returns the revision string.
|
java.lang.String |
globalInfo() |
java.lang.String |
graph()
Returns graph describing the classifier (if possible).
|
int |
graphType()
Returns the type of graph this classifier
represents.
|
boolean |
implementsMoreEfficientBatchPrediction()
Returns true if the base classifier implements BatchPredictor and is able
to generate batch predictions efficiently
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
java.lang.String |
minimizeExpectedCostTipText() |
java.lang.String |
onDemandDirectoryTipText() |
void |
setBatchSize(java.lang.String size)
Set the batch size to use.
|
void |
setCostMatrix(CostMatrix newCostMatrix)
Sets the misclassification cost matrix.
|
void |
setCostMatrixSource(SelectedTag newMethod)
Sets the source location of the cost matrix.
|
void |
setMinimizeExpectedCost(boolean newMinimizeExpectedCost)
Set the value of MinimizeExpectedCost.
|
void |
setOnDemandDirectory(java.io.File newDir)
Sets the directory that will be searched for cost files when
loading on demand.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
java.lang.String |
toString()
Output a representation of this classifier
|
getSeed, seedTipText, setSeedclassifierTipText, getClassifier, postExecution, preExecution, setClassifierclassifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesequals, getClass, hashCode, notify, notifyAll, wait, wait, waitmakeCopypublic static final int MATRIX_ON_DEMAND
public static final int MATRIX_SUPPLIED
public static final Tag[] TAGS_MATRIX_SOURCE
public java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class RandomizableSingleClassifierEnhancerpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
-M Minimize expected misclassification cost. Default is to reweight training instances according to costs per class
-C <cost file name> File name of a cost matrix to use. If this is not supplied, a cost matrix will be loaded on demand. The name of the on-demand file is the relation name of the training data plus ".cost", and the path to the on-demand file is specified with the -N option.
-N <directory> Name of a directory to search for cost files when loading costs on demand (default current directory).
-cost-matrix <matrix> The cost matrix in Matlab single line format.
-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.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 consoleOptions after -- are passed to the designated classifier.
setOptions in interface OptionHandlersetOptions in class RandomizableSingleClassifierEnhanceroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedpublic java.lang.String[] getOptions()
getOptions in interface OptionHandlergetOptions in class RandomizableSingleClassifierEnhancerpublic java.lang.String globalInfo()
public java.lang.String costMatrixSourceTipText()
public SelectedTag getCostMatrixSource()
public void setCostMatrixSource(SelectedTag newMethod)
newMethod - the cost matrix location method.public java.lang.String onDemandDirectoryTipText()
public java.io.File getOnDemandDirectory()
public void setOnDemandDirectory(java.io.File newDir)
newDir - The cost file search directory.public java.lang.String minimizeExpectedCostTipText()
public boolean getMinimizeExpectedCost()
public void setMinimizeExpectedCost(boolean newMinimizeExpectedCost)
newMinimizeExpectedCost - Value to assign to MinimizeExpectedCost.public java.lang.String costMatrixTipText()
public CostMatrix getCostMatrix()
public void setCostMatrix(CostMatrix newCostMatrix)
newCostMatrix - the cost matrixpublic Capabilities getCapabilities()
getCapabilities in interface ClassifiergetCapabilities in interface CapabilitiesHandlergetCapabilities in class SingleClassifierEnhancerCapabilitiespublic void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier in interface Classifierdata - the training datajava.lang.Exception - if the classifier could not be built successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to be classifiedjava.lang.Exception - if instance could not be classified
successfullypublic double[][] distributionsForInstances(Instances insts) throws java.lang.Exception
distributionsForInstances in interface BatchPredictordistributionsForInstances in class AbstractClassifierinsts - the instances to get predictions forjava.lang.Exception - if a problem occurspublic java.lang.String batchSizeTipText()
batchSizeTipText in class AbstractClassifierpublic void setBatchSize(java.lang.String size)
setBatchSize in interface BatchPredictorsetBatchSize in class AbstractClassifiersize - the batch size to usepublic java.lang.String getBatchSize()
getBatchSize in interface BatchPredictorgetBatchSize in class AbstractClassifierpublic boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction in interface BatchPredictorimplementsMoreEfficientBatchPrediction in class AbstractClassifierpublic int graphType()
public java.lang.String graph()
throws java.lang.Exception
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifierpublic static void main(java.lang.String[] argv)
argv - should contain the following arguments:
-t training file [-T test file] [-c class index]