All Packages Class Hierarchy This Package Previous Next Index WEKA's home
java.lang.Object | +----weka.classifiers.Classifier | +----weka.classifiers.MetaCost
Pedro Domingos (1999). MetaCost: A general method for making classifiers cost-sensitive, Proceedings of the Fifth International Conference on Knowledge Discovery and Data Mining, pp. 155-164. Also available online at http://www.cs.washington.edu/homes/pedrod/kdd99.ps.gz.
This classifier should produce similar results to one created by passing the base learner to Bagging, which is in turn passed to a CostSensitiveClassifier operating on minimum expected cost. The difference is that MetaCost produces a single cost-sensitive classifier of the base learner, giving the benefits of fast classification and interpretable output (if the base learner itself is interpretable). This implementation uses all bagging iterations when reclassifying training data (the MetaCost paper reports a marginal improvement when only those iterations containing each training instance are used in reclassifying that instance).
Valid options are:
-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 -D option.
-D directory
Name of a directory to search for cost files when loading costs on demand
(default current directory).
-I num
Set the number of bagging iterations (default 10).
-S seed
Random number seed used when reweighting by resampling (default 1).
-P num
Size of each bag, as a percentage of the training size (default 100).
Options after -- are passed to the designated classifier.
public static final int MATRIX_ON_DEMAND
public static final int MATRIX_SUPPLIED
public static final Tag[] TAGS_MATRIX_SOURCE
public MetaCost()
public java.util.Enumeration listOptions()
public void setOptions(java.lang.String options[]) throws java.lang.Exception
-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 -D option.
-D directory
Name of a directory to search for cost files when loading costs on demand
(default current directory).
-I num
Set the number of bagging iterations (default 10).
-S seed
Random number seed used when reweighting by resampling (default 1).
-P num
Size of each bag, as a percentage of the training size (default 100).
Options after -- are passed to the designated classifier.
options
- the list of options as an array of strings
public java.lang.String[] getOptions()
public SelectedTag getCostMatrixSource()
public void setCostMatrixSource(SelectedTag newMethod)
newMethod
- the cost matrix location method.
public java.io.File getOnDemandDirectory()
public void setOnDemandDirectory(java.io.File newDir)
newDir
- The cost file search directory.
public void setClassifier(Classifier classifier)
classifier
- the distribution classifier with all options set.
public Classifier getClassifier()
public int getBagSizePercent()
public void setBagSizePercent(int newBagSizePercent)
newBagSizePercent
- the bag size, as a percentage.
public void setNumIterations(int numIterations)
public int getNumIterations()
public CostMatrix getCostMatrix()
public void setCostMatrix(CostMatrix newCostMatrix)
the
- cost matrix
public void setSeed(int seed)
seed
- the seed for resampling
public int getSeed()
public void buildClassifier(Instances data) throws java.lang.Exception
data
- the training data
public double classifyInstance(Instance instance) throws java.lang.Exception
instance
- the instance to be classified
public 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]
All Packages Class Hierarchy This Package Previous Next Index WEKA's home