All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.CostSensitiveClassifier
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.CostSensitiveClassifier
- public class CostSensitiveClassifier
- extends Classifier
- implements OptionHandler
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). The minimum expected cost approach requires that the base classifier
be a DistributionClassifier.
Valid options are:
-M
Minimize expected misclassification cost. The base classifier must
produce probability estimates i.e. a DistributionClassifier).
(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 (required).
-S seed
Random number seed used when reweighting by resampling (default 1).
Options after -- are passed to the designated classifier.
- Version:
- $Revision: 1.1 $
- Author:
- Len Trigg (len@intelligenesis.net)
-
CostSensitiveClassifier()
-
-
buildClassifier(Instances)
- Builds the model of the base learner.
-
classifyInstance(Instance)
- Classifies a given instance by choosing the class with the minimum
expected misclassification cost.
-
getClassifier()
- Gets the distribution classifier used.
-
getCostMatrix()
- Gets the misclassification cost matrix.
-
getMinimizeExpectedCost()
- Gets the value of MinimizeExpectedCost.
-
getOptions()
- Gets the current settings of the Classifier.
-
getSeed()
- Get seed for resampling.
-
listOptions()
- Returns an enumeration describing the available options
-
main(String[])
- Main method for testing this class.
-
setClassifier(Classifier)
- Sets the distribution classifier
-
setCostMatrix(CostMatrix)
- Sets the misclassification cost matrix.
-
setMinimizeExpectedCost(boolean)
- Set the value of MinimizeExpectedCost.
-
setOptions(String[])
- Parses a given list of options.
-
setSeed(int)
- Set seed for resampling.
-
toString()
- Output a representation of this classifier
CostSensitiveClassifier
public CostSensitiveClassifier()
listOptions
public Enumeration listOptions()
- Returns an enumeration describing the available options
- Returns:
- an enumeration of all the available options
setOptions
public void setOptions(String options[]) throws Exception
- Parses a given list of options. Valid options are:
-M
Minimize expected misclassification cost. The base classifier must
produce probability estimates i.e. a DistributionClassifier).
(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 (required).
-S seed
Random number seed used when reweighting by resampling (default 1).
Options after -- are passed to the designated classifier.
- 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 settings of the Classifier.
- Returns:
- an array of strings suitable for passing to setOptions
getMinimizeExpectedCost
public boolean getMinimizeExpectedCost()
- Gets the value of MinimizeExpectedCost.
- Returns:
- Value of MinimizeExpectedCost.
setMinimizeExpectedCost
public void setMinimizeExpectedCost(boolean newMinimizeExpectedCost)
- Set the value of MinimizeExpectedCost.
- Parameters:
- newMinimizeExpectedCost - Value to assign to MinimizeExpectedCost.
setClassifier
public void setClassifier(Classifier classifier)
- Sets the distribution classifier
- Parameters:
- classifier - the distribution classifier with all options set.
getClassifier
public Classifier getClassifier()
- Gets the distribution classifier used.
- Returns:
- the classifier
getCostMatrix
public CostMatrix getCostMatrix()
- Gets the misclassification cost matrix.
- Returns:
- the cost matrix
setCostMatrix
public void setCostMatrix(CostMatrix newCostMatrix)
- Sets the misclassification cost matrix.
- Parameters:
- the - cost matrix
setSeed
public void setSeed(int seed)
- Set seed for resampling.
- Parameters:
- seed - the seed for resampling
getSeed
public int getSeed()
- Get seed for resampling.
- Returns:
- the seed for resampling
buildClassifier
public void buildClassifier(Instances data) throws Exception
- Builds the model of the base learner.
- Parameters:
- data - the training data
- Throws: Exception
- if the classifier could not be built successfully
- Overrides:
- buildClassifier in class Classifier
classifyInstance
public double classifyInstance(Instance instance) throws Exception
- Classifies a given instance by choosing the class with the minimum
expected misclassification cost.
- Parameters:
- instance - the instance to be classified
- Throws: Exception
- if instance could not be classified
successfully
- Overrides:
- classifyInstance in class Classifier
toString
public String toString()
- Output a representation of this classifier
- Overrides:
- toString in class Object
main
public static void main(String argv[])
- Main method for testing this class.
- Parameters:
- argv - should contain the following arguments:
-t training file [-T test file] [-c class index]
All Packages Class Hierarchy This Package Previous Next Index WEKA's home