|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.classifiers.AbstractClassifier
weka.classifiers.SingleClassifierEnhancer
weka.classifiers.RandomizableSingleClassifierEnhancer
weka.classifiers.meta.CostSensitiveClassifier
public class CostSensitiveClassifier
A metaclassifier that makes its base classifier cost-sensitive. Two methods can be used to introduce cost-sensitivity: reweighting training instances according to the total cost assigned to each class; or predicting the class with minimum expected misclassification cost (rather than the most likely class). Performance can often be improved by using a Bagged classifier to improve the probability estimates of the base classifier.
Valid options are:-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.
| Field Summary | |
|---|---|
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 |
| Fields inherited from interface weka.core.Drawable |
|---|
BayesNet, Newick, NOT_DRAWABLE, TREE |
| Constructor Summary | |
|---|---|
CostSensitiveClassifier()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
buildClassifier(Instances data)
Builds the model of the base learner. |
String |
costMatrixSourceTipText()
|
String |
costMatrixTipText()
|
double[] |
distributionForInstance(Instance instance)
Returns class probabilities. |
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. |
File |
getOnDemandDirectory()
Returns the directory that will be searched for cost files when loading on demand. |
String[] |
getOptions()
Gets the current settings of the Classifier. |
String |
getRevision()
Returns the revision string. |
String |
globalInfo()
|
String |
graph()
Returns graph describing the classifier (if possible). |
int |
graphType()
Returns the type of graph this classifier represents. |
Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(String[] argv)
Main method for testing this class. |
String |
minimizeExpectedCostTipText()
|
String |
onDemandDirectoryTipText()
|
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(File newDir)
Sets the directory that will be searched for cost files when loading on demand. |
void |
setOptions(String[] options)
Parses a given list of options. |
String |
toString()
Output a representation of this classifier |
| Methods inherited from class weka.classifiers.RandomizableSingleClassifierEnhancer |
|---|
getSeed, seedTipText, setSeed |
| Methods inherited from class weka.classifiers.SingleClassifierEnhancer |
|---|
classifierTipText, getClassifier, setClassifier |
| Methods inherited from class weka.classifiers.AbstractClassifier |
|---|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MATRIX_ON_DEMAND
public static final int MATRIX_SUPPLIED
public static final Tag[] TAGS_MATRIX_SOURCE
| Constructor Detail |
|---|
public CostSensitiveClassifier()
| Method Detail |
|---|
public Enumeration listOptions()
listOptions in interface OptionHandlerlistOptions in class RandomizableSingleClassifierEnhancer
public void setOptions(String[] options)
throws 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 strings
Exception - if an option is not supportedpublic String[] getOptions()
getOptions in interface OptionHandlergetOptions in class RandomizableSingleClassifierEnhancerpublic String globalInfo()
public String costMatrixSourceTipText()
public SelectedTag getCostMatrixSource()
public void setCostMatrixSource(SelectedTag newMethod)
newMethod - the cost matrix location method.public String onDemandDirectoryTipText()
public File getOnDemandDirectory()
public void setOnDemandDirectory(File newDir)
newDir - The cost file search directory.public String minimizeExpectedCostTipText()
public boolean getMinimizeExpectedCost()
public void setMinimizeExpectedCost(boolean newMinimizeExpectedCost)
newMinimizeExpectedCost - Value to assign to MinimizeExpectedCost.public 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 SingleClassifierEnhancerCapabilities
public void buildClassifier(Instances data)
throws Exception
buildClassifier in interface Classifierdata - the training data
Exception - if the classifier could not be built successfully
public double[] distributionForInstance(Instance instance)
throws Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to be classified
Exception - if instance could not be classified
successfullypublic int graphType()
graphType in interface Drawable
public String graph()
throws Exception
graph in interface DrawableException - if the classifier cannot be graphedpublic String toString()
toString in class Objectpublic String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifierpublic static void main(String[] argv)
argv - should contain the following arguments:
-t training file [-T test file] [-c class index]
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||