类 AttributeSelection

java.lang.Object
weka.attributeSelection.AttributeSelection
所有已实现的接口:
Serializable, RevisionHandler

public class AttributeSelection extends Object implements Serializable, RevisionHandler
Attribute selection class. Takes the name of a search class and an evaluation class on the command line.

Valid options are:

-h
Display help.

-i <name of input file>
Specify the training data file.

-c <class index>
The index of the attribute to use as the class.

-s <search method>
The full class name of the search method followed by search method options (if any).
Eg. -s "weka.attributeSelection.BestFirst -N 10"

-x <number of folds>
Perform a cross validation.

-n <random number seed>
Specify a random number seed. Use in conjuction with -x. (Default = 1).

------------------------------------------------------------------------

Example usage as the main of an attribute evaluator (called FunkyEvaluator):

 public static void main(String [] args) {
   runEvaluator(new FunkyEvaluator(), args);
 }
 

------------------------------------------------------------------------

版本:
$Revision: 11851 $
作者:
Mark Hall (mhall@cs.waikato.ac.nz)
另请参阅:
  • 构造器详细资料

    • AttributeSelection

      public AttributeSelection()
      constructor. Sets defaults for each member varaible. Default attribute evaluator is CfsSubsetEval; default search method is BestFirst.
  • 方法详细资料

    • numberAttributesSelected

      public int numberAttributesSelected() throws Exception
      Return the number of attributes selected from the most recent run of attribute selection
      返回:
      the number of attributes selected
      抛出:
      Exception
    • selectedAttributes

      public int[] selectedAttributes() throws Exception
      get the final selected set of attributes.
      返回:
      an array of attribute indexes
      抛出:
      Exception - if attribute selection has not been performed yet
    • rankedAttributes

      public double[][] rankedAttributes() throws Exception
      get the final ranking of the attributes.
      返回:
      a two dimensional array of ranked attribute indexes and their associated merit scores as doubles.
      抛出:
      Exception - if a ranking has not been produced
    • setEvaluator

      public void setEvaluator(ASEvaluation evaluator)
      set the attribute/subset evaluator
      参数:
      evaluator - the evaluator to use
    • setSearch

      public void setSearch(ASSearch search)
      set the search method
      参数:
      search - the search method to use
    • setFolds

      public void setFolds(int folds)
      set the number of folds for cross validation
      参数:
      folds - the number of folds
    • setRanking

      public void setRanking(boolean r)
      produce a ranking (if possible with the set search and evaluator)
      参数:
      r - true if a ranking is to be produced
    • setXval

      public void setXval(boolean x)
      do a cross validation
      参数:
      x - true if a cross validation is to be performed
    • setSeed

      public void setSeed(int s)
      set the seed for use in cross validation
      参数:
      s - the seed
    • toResultsString

      public String toResultsString()
      get a description of the attribute selection
      返回:
      a String describing the results of attribute selection
    • reduceDimensionality

      public Instances reduceDimensionality(Instances in) throws Exception
      reduce the dimensionality of a set of instances to include only those attributes chosen by the last run of attribute selection.
      参数:
      in - the instances to be reduced
      返回:
      a dimensionality reduced set of instances
      抛出:
      Exception - if the instances can't be reduced
    • reduceDimensionality

      public Instance reduceDimensionality(Instance in) throws Exception
      reduce the dimensionality of a single instance to include only those attributes chosen by the last run of attribute selection.
      参数:
      in - the instance to be reduced
      返回:
      a dimensionality reduced instance
      抛出:
      Exception - if the instance can't be reduced
    • SelectAttributes

      public static String SelectAttributes(ASEvaluation ASEvaluator, String[] options) throws Exception
      Perform attribute selection with a particular evaluator and a set of options specifying search method and input file etc.
      参数:
      ASEvaluator - an evaluator object
      options - an array of options, not only for the evaluator but also the search method (if any) and an input data file
      返回:
      the results of attribute selection as a String
      抛出:
      Exception - if no training file is set
    • CVResultsString

      public String CVResultsString() throws Exception
      returns a string summarizing the results of repeated attribute selection runs on splits of a dataset.
      返回:
      a summary of attribute selection results
      抛出:
      Exception - if no attribute selection has been performed.
    • selectAttributesCVSplit

      public void selectAttributesCVSplit(Instances split) throws Exception
      Select attributes for a split of the data. Calling this function updates the statistics on attribute selection. CVResultsString() returns a string summarizing the results of repeated calls to this function. Assumes that splits are from the same dataset--- ie. have the same number and types of attributes as previous splits.
      参数:
      split - the instances to select attributes from
      抛出:
      Exception - if an error occurs
    • CrossValidateAttributes

      public String CrossValidateAttributes() throws Exception
      Perform a cross validation for attribute selection. With subset evaluators the number of times each attribute is selected over the cross validation is reported. For attribute evaluators, the average merit and average ranking + std deviation is reported for each attribute.
      返回:
      the results of cross validation as a String
      抛出:
      Exception - if an error occurs during cross validation
    • SelectAttributes

      public void SelectAttributes(Instances data) throws Exception
      Perform attribute selection on the supplied training instances.
      参数:
      data - the instances to select attributes from
      抛出:
      Exception - if there is a problem during selection
    • SelectAttributes

      public static String SelectAttributes(ASEvaluation ASEvaluator, String[] options, Instances train) throws Exception
      Perform attribute selection with a particular evaluator and a set of options specifying search method and options for the search method and evaluator.
      参数:
      ASEvaluator - an evaluator object
      options - an array of options, not only for the evaluator but also the search method (if any) and an input data file
      train - the input instances
      返回:
      the results of attribute selection as a String
      抛出:
      Exception - if incorrect options are supplied
    • main

      public static void main(String[] args)
      Main method for testing this class.
      参数:
      args - the options
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      返回:
      the revision