|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.meta.CostSensitiveClassifier
This metaclassifier 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).
Valid options are:
-M
Minimize expected misclassification cost.
(default is to reweight training instances according to costs per class)
-W classname
Specify the full class name of a classifier (required).
-C cost file
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).
-S seed
Random number seed used when reweighting by resampling (default 1).
Options after -- are passed to the designated classifier.
Field Summary | |
protected Classifier |
m_Classifier
The classifier |
protected java.lang.String |
m_CostFile
The name of the cost file, for command line options |
protected CostMatrix |
m_CostMatrix
The cost matrix |
protected int |
m_MatrixSource
Indicates the current cost matrix source |
protected boolean |
m_MinimizeExpectedCost
True if the costs should be used by selecting the minimum expected cost (false means weight training data by the costs) |
protected java.io.File |
m_OnDemandDirectory
The directory used when loading cost files on demand, null indicates current directory |
protected int |
m_Seed
Seed for reweighting using resampling. |
static int |
MATRIX_ON_DEMAND
|
static int |
MATRIX_SUPPLIED
|
static Tag[] |
TAGS_MATRIX_SOURCE
|
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Fields inherited from interface weka.core.Drawable |
BayesNet, NOT_DRAWABLE, TREE |
Constructor Summary | |
CostSensitiveClassifier()
|
Method Summary | |
void |
buildClassifier(Instances data)
Builds the model of the base learner. |
java.lang.String |
classifierTipText()
|
java.lang.String |
costMatrixSourceTipText()
|
java.lang.String |
costMatrixTipText()
|
double[] |
distributionForInstance(Instance instance)
Returns class probabilities. |
Classifier |
getClassifier()
Gets the classifier used. |
protected java.lang.String |
getClassifierSpec()
Gets the classifier specification string, which contains the class name of the classifier and any options to 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. |
int |
getSeed()
Get seed for resampling. |
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. |
java.util.Enumeration |
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()
|
java.lang.String |
seedTipText()
|
void |
setClassifier(Classifier classifier)
Sets the distribution classifier |
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. |
void |
setSeed(int seed)
Set seed for resampling. |
java.lang.String |
toString()
Output a representation of this classifier |
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, 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
protected int m_MatrixSource
protected java.io.File m_OnDemandDirectory
protected java.lang.String m_CostFile
protected CostMatrix m_CostMatrix
protected Classifier m_Classifier
protected int m_Seed
protected boolean m_MinimizeExpectedCost
Constructor Detail |
public CostSensitiveClassifier()
Method Detail |
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public 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)
-W classname
Specify the full class name of a classifier (required).
-C cost file
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).
-S seed
Random number seed used when reweighting by resampling (default 1).
Options after -- are passed to the designated classifier.
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public 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 classifierTipText()
public void setClassifier(Classifier classifier)
classifier
- the classifier with all options set.public Classifier getClassifier()
protected java.lang.String getClassifierSpec()
public java.lang.String costMatrixTipText()
public CostMatrix getCostMatrix()
public void setCostMatrix(CostMatrix newCostMatrix)
public java.lang.String seedTipText()
public void setSeed(int seed)
seed
- the seed for resamplingpublic int getSeed()
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- the training data
java.lang.Exception
- if the classifier could not be built successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if instance could not be classified
successfullypublic int graphType()
graphType
in interface Drawable
public java.lang.String graph() throws java.lang.Exception
graph
in interface Drawable
java.lang.Exception
- if the classifier cannot be graphedpublic java.lang.String toString()
public static void main(java.lang.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 |