类 CostSensitiveClassifier

所有已实现的接口:
Serializable, Cloneable, CapabilitiesHandler, Drawable, OptionHandler, Randomizable, RevisionHandler

public class CostSensitiveClassifier extends RandomizableSingleClassifierEnhancer implements OptionHandler, Drawable
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 console
Options after -- are passed to the designated classifier.

版本:
$Revision: 1.29 $
作者:
Len Trigg (len@reeltwo.com)
另请参阅:
  • 字段详细资料

    • MATRIX_ON_DEMAND

      public static final int MATRIX_ON_DEMAND
      load cost matrix on demand
      另请参阅:
    • MATRIX_SUPPLIED

      public static final int MATRIX_SUPPLIED
      use explicit cost matrix
      另请参阅:
    • TAGS_MATRIX_SOURCE

      public static final Tag[] TAGS_MATRIX_SOURCE
      Specify possible sources of the cost matrix
  • 构造器详细资料

    • CostSensitiveClassifier

      public CostSensitiveClassifier()
      Default constructor.
  • 方法详细资料

    • listOptions

      public Enumeration listOptions()
      Returns an enumeration describing the available options.
      指定者:
      listOptions 在接口中 OptionHandler
      覆盖:
      listOptions 在类中 RandomizableSingleClassifierEnhancer
      返回:
      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. 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 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

      public String[] getOptions()
      Gets the current settings of the Classifier.
      指定者:
      getOptions 在接口中 OptionHandler
      覆盖:
      getOptions 在类中 RandomizableSingleClassifierEnhancer
      返回:
      an array of strings suitable for passing to setOptions
    • globalInfo

      public String globalInfo()
      返回:
      a description of the classifier suitable for displaying in the explorer/experimenter gui
    • costMatrixSourceTipText

      public String costMatrixSourceTipText()
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getCostMatrixSource

      public SelectedTag 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

      public void setCostMatrixSource(SelectedTag newMethod)
      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

      public String onDemandDirectoryTipText()
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getOnDemandDirectory

      public File getOnDemandDirectory()
      Returns the directory that will be searched for cost files when loading on demand.
      返回:
      The cost file search directory.
    • setOnDemandDirectory

      public void setOnDemandDirectory(File newDir)
      Sets the directory that will be searched for cost files when loading on demand.
      参数:
      newDir - The cost file search directory.
    • minimizeExpectedCostTipText

      public String minimizeExpectedCostTipText()
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getMinimizeExpectedCost

      public boolean getMinimizeExpectedCost()
      Gets the value of MinimizeExpectedCost.
      返回:
      Value of MinimizeExpectedCost.
    • setMinimizeExpectedCost

      public void setMinimizeExpectedCost(boolean newMinimizeExpectedCost)
      Set the value of MinimizeExpectedCost.
      参数:
      newMinimizeExpectedCost - Value to assign to MinimizeExpectedCost.
    • costMatrixTipText

      public String costMatrixTipText()
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getCostMatrix

      public CostMatrix getCostMatrix()
      Gets the misclassification cost matrix.
      返回:
      the cost matrix
    • setCostMatrix

      public void setCostMatrix(CostMatrix newCostMatrix)
      Sets the misclassification cost matrix.
      参数:
      newCostMatrix - the cost matrix
    • getCapabilities

      public Capabilities getCapabilities()
      Returns default capabilities of the classifier.
      指定者:
      getCapabilities 在接口中 CapabilitiesHandler
      覆盖:
      getCapabilities 在类中 SingleClassifierEnhancer
      返回:
      the capabilities of this classifier
      另请参阅:
    • buildClassifier

      public void buildClassifier(Instances data) throws Exception
      Builds the model of the base learner.
      指定者:
      buildClassifier 在类中 Classifier
      参数:
      data - the training data
      抛出:
      Exception - if the classifier could not be built successfully
    • distributionForInstance

      public double[] distributionForInstance(Instance instance) throws Exception
      Returns class probabilities. When minimum expected cost approach is chosen, returns probability one for class with the minimum expected misclassification cost. Otherwise it returns the probability distribution returned by the base classifier.
      覆盖:
      distributionForInstance 在类中 Classifier
      参数:
      instance - the instance to be classified
      返回:
      the computed distribution for the given instance
      抛出:
      Exception - if instance could not be classified successfully
    • graphType

      public int graphType()
      Returns the type of graph this classifier represents.
      指定者:
      graphType 在接口中 Drawable
      返回:
      the type of graph this classifier represents
    • graph

      public String graph() throws Exception
      Returns graph describing the classifier (if possible).
      指定者:
      graph 在接口中 Drawable
      返回:
      the graph of the classifier in dotty format
      抛出:
      Exception - if the classifier cannot be graphed
    • toString

      public String toString()
      Output a representation of this classifier
      覆盖:
      toString 在类中 Object
      返回:
      a string representation of the classifier
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      覆盖:
      getRevision 在类中 Classifier
      返回:
      the revision
    • main

      public static void main(String[] argv)
      Main method for testing this class.
      参数:
      argv - should contain the following arguments: -t training file [-T test file] [-c class index]