类 MetaCost
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.SingleClassifierEnhancer
weka.classifiers.RandomizableSingleClassifierEnhancer
weka.classifiers.meta.MetaCost
- 所有已实现的接口:
Serializable
,Cloneable
,CapabilitiesHandler
,OptionHandler
,Randomizable
,RevisionHandler
,TechnicalInformationHandler
public class MetaCost
extends RandomizableSingleClassifierEnhancer
implements TechnicalInformationHandler
This metaclassifier makes its base classifier cost-sensitive using the method specified in
Pedro Domingos: MetaCost: A general method for making classifiers cost-sensitive. In: Fifth International Conference on Knowledge Discovery and Data Mining, 155-164, 1999.
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). BibTeX:
Pedro Domingos: MetaCost: A general method for making classifiers cost-sensitive. In: Fifth International Conference on Knowledge Discovery and Data Mining, 155-164, 1999.
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). BibTeX:
@inproceedings{Domingos1999, author = {Pedro Domingos}, booktitle = {Fifth International Conference on Knowledge Discovery and Data Mining}, pages = {155-164}, title = {MetaCost: A general method for making classifiers cost-sensitive}, year = {1999} }Valid options are:
-I <num> Number of bagging iterations. (default 10)
-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.
-P Size of each bag, as a percentage of the training set size. (default 100)
-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.
- 版本:
- $Revision: 1.24 $
- 作者:
- Len Trigg (len@reeltwo.com)
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final int
load cost matrix on demandstatic final int
use explicit matrixstatic final Tag[]
Specify possible sources of the cost matrix -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明Returns the tip text for this propertyvoid
buildClassifier
(Instances data) Builds the model of the base learner.Returns the tip text for this propertyReturns the tip text for this propertydouble[]
distributionForInstance
(Instance instance) Classifies a given instance after filtering.int
Gets the size of each bag, as a percentage of the training set size.Returns default capabilities of the classifier.Gets the misclassification cost matrix.Gets the source location method of the cost matrix.int
Gets the number of bagging iterationsReturns the directory that will be searched for cost files when loading on demand.String[]
Gets the current settings of the Classifier.Returns the revision string.Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.Returns a string describing classifierReturns an enumeration describing the available options.static void
Main method for testing this class.Returns the tip text for this propertyReturns the tip text for this propertyvoid
setBagSizePercent
(int newBagSizePercent) Sets the size of each bag, as a percentage of the training set size.void
setCostMatrix
(CostMatrix newCostMatrix) Sets the misclassification cost matrix.void
setCostMatrixSource
(SelectedTag newMethod) Sets the source location of the cost matrix.void
setNumIterations
(int numIterations) Sets the number of bagging iterationsvoid
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.toString()
Output a representation of this classifier从类继承的方法 weka.classifiers.RandomizableSingleClassifierEnhancer
getSeed, seedTipText, setSeed
从类继承的方法 weka.classifiers.SingleClassifierEnhancer
classifierTipText, getClassifier, setClassifier
从类继承的方法 weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
-
字段详细资料
-
构造器详细资料
-
MetaCost
public MetaCost()
-
-
方法详细资料
-
globalInfo
Returns a string describing classifier- 返回:
- a description suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- 指定者:
getTechnicalInformation
在接口中TechnicalInformationHandler
- 返回:
- the technical information about this class
-
listOptions
Returns an enumeration describing the available options.- 指定者:
listOptions
在接口中OptionHandler
- 覆盖:
listOptions
在类中RandomizableSingleClassifierEnhancer
- 返回:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-I <num> Number of bagging iterations. (default 10)
-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.
-P Size of each bag, as a percentage of the training set size. (default 100)
-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 console
Options after -- are passed to the designated classifier.- 指定者:
setOptions
在接口中OptionHandler
- 覆盖:
setOptions
在类中RandomizableSingleClassifierEnhancer
- 参数:
options
- the list of options as an array of strings- 抛出:
Exception
- if an option is not supported
-
getOptions
Gets the current settings of the Classifier.- 指定者:
getOptions
在接口中OptionHandler
- 覆盖:
getOptions
在类中RandomizableSingleClassifierEnhancer
- 返回:
- an array of strings suitable for passing to setOptions
-
costMatrixSourceTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCostMatrixSource
Gets the source location method of the cost matrix. Will be one of MATRIX_ON_DEMAND or MATRIX_SUPPLIED.- 返回:
- the cost matrix source.
-
setCostMatrixSource
Sets the source location of the cost matrix. Values other than MATRIX_ON_DEMAND or MATRIX_SUPPLIED will be ignored.- 参数:
newMethod
- the cost matrix location method.
-
onDemandDirectoryTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getOnDemandDirectory
Returns the directory that will be searched for cost files when loading on demand.- 返回:
- The cost file search directory.
-
setOnDemandDirectory
Sets the directory that will be searched for cost files when loading on demand.- 参数:
newDir
- The cost file search directory.
-
bagSizePercentTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getBagSizePercent
public int getBagSizePercent()Gets the size of each bag, as a percentage of the training set size.- 返回:
- the bag size, as a percentage.
-
setBagSizePercent
public void setBagSizePercent(int newBagSizePercent) Sets the size of each bag, as a percentage of the training set size.- 参数:
newBagSizePercent
- the bag size, as a percentage.
-
numIterationsTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNumIterations
public void setNumIterations(int numIterations) Sets the number of bagging iterations- 参数:
numIterations
- the number of iterations to use
-
getNumIterations
public int getNumIterations()Gets the number of bagging iterations- 返回:
- the maximum number of bagging iterations
-
costMatrixTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCostMatrix
Gets the misclassification cost matrix.- 返回:
- the cost matrix
-
setCostMatrix
Sets the misclassification cost matrix.- 参数:
newCostMatrix
- the cost matrix
-
getCapabilities
Returns default capabilities of the classifier.- 指定者:
getCapabilities
在接口中CapabilitiesHandler
- 覆盖:
getCapabilities
在类中SingleClassifierEnhancer
- 返回:
- the capabilities of this classifier
- 另请参阅:
-
buildClassifier
Builds the model of the base learner.- 指定者:
buildClassifier
在类中Classifier
- 参数:
data
- the training data- 抛出:
Exception
- if the classifier could not be built successfully
-
distributionForInstance
Classifies a given instance after filtering.- 覆盖:
distributionForInstance
在类中Classifier
- 参数:
instance
- the instance to be classified- 返回:
- the class distribution for the given instance
- 抛出:
Exception
- if instance could not be classified successfully
-
toString
Output a representation of this classifier -
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 覆盖:
getRevision
在类中Classifier
- 返回:
- the revision
-
main
Main method for testing this class.- 参数:
argv
- should contain the following arguments: -t training file [-T test file] [-c class index]
-