All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.attributeSelection.AttributeSelection

java.lang.Object
   |
   +----weka.attributeSelection.AttributeSelection

public class AttributeSelection
extends Object
implements Serializable
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
Specify the training arff file.

-C
The index of the attribute to use as the class.

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

-X
Perform a cross validation.

-N
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) {
   try {
     ASEvaluator eval = new FunkyEvaluator();
     System.out.println(SelectAttributes(Evaluator, args));
   } catch (Exception e) {
     System.err.println(e.getMessage());
   }
 }
  

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

Version:
$Revision: 1.11 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)

Constructor Index

 o AttributeSelection()
constructor.

Method Index

 o CrossValidateAttributes()
Perform a cross validation for attribute selection.
 o CVResultsString()
returns a string summarizing the results of repeated attribute selection runs on splits of a dataset.
 o main(String[])
Main method for testing this class.
 o rankedAttributes()
get the final ranking of the attributes.
 o SelectAttributes(ASEvaluation, String[])
Perform attribute selection with a particular evaluator and a set of options specifying search method and input file etc.
 o SelectAttributes(ASEvaluation, String[], Instances)
Perform attribute selection with a particular evaluator and a set of options specifying search method and options for the search method and evaluator.
 o SelectAttributes(Instances)
Perform attribute selection on the supplied training instances.
 o selectAttributesCVSplit(Instances)
Select attributes for a split of the data.
 o selectedAttributes()
get the final selected set of attributes.
 o setEvaluator(ASEvaluation)
set the attribute/subset evaluator
 o setFolds(int)
set the number of folds for cross validation
 o setRanking(boolean)
produce a ranking (if possible with the set search an evaluator
 o setSearch(ASSearch)
set the search method
 o setSeed(int)
set the seed for use in cross validation
 o setThreshold(double)
set the threshold by which to select features from a ranked list
 o setXval(boolean)
do a cross validation
 o toResultsString()
get a description of the attribute selection

Constructors

 o AttributeSelection
 public AttributeSelection()
constructor. Sets defaults for each member varaible. Default attribute evaluator is CfsSubsetEval; default search method is BestFirst.

Methods

 o selectedAttributes
 public int[] selectedAttributes() throws Exception
get the final selected set of attributes.

Returns:
an array of attribute indexes
Throws: Exception
if attribute selection has not been performed yet
 o rankedAttributes
 public double[][] rankedAttributes() throws Exception
get the final ranking of the attributes.

Returns:
a two dimensional array of ranked attribute indexes and their associated merit scores as doubles.
Throws: Exception
if a ranking has not been produced
 o setEvaluator
 public void setEvaluator(ASEvaluation evaluator)
set the attribute/subset evaluator

Parameters:
evaluator - the evaluator to use
 o setSearch
 public void setSearch(ASSearch search)
set the search method

Parameters:
search - the search method to use
 o setFolds
 public void setFolds(int folds)
set the number of folds for cross validation

Parameters:
folds - the number of folds
 o setRanking
 public void setRanking(boolean r)
produce a ranking (if possible with the set search an evaluator

Parameters:
r - true if a ranking is to be produced
 o setXval
 public void setXval(boolean x)
do a cross validation

Parameters:
x - true if a cross validation is to be performed
 o setSeed
 public void setSeed(int s)
set the seed for use in cross validation

Parameters:
s - the seed
 o setThreshold
 public void setThreshold(double t)
set the threshold by which to select features from a ranked list

Parameters:
t - the threshold
 o toResultsString
 public String toResultsString()
get a description of the attribute selection

Returns:
a String describing the results of attribute selection
 o 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.

Parameters:
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
Returns:
the results of attribute selection as a String
Throws: Exception
if no training file is set
 o CVResultsString
 public String CVResultsString() throws Exception
returns a string summarizing the results of repeated attribute selection runs on splits of a dataset.

Returns:
a summary of attribute selection results
Throws: Exception
if no attribute selection has been performed.
 o 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.

Parameters:
split - the instances to select attributes from
Throws: Exception
if an error occurs
 o 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.

Returns:
the results of cross validation as a String
Throws: Exception
if an error occurs during cross validation
 o SelectAttributes
 public void SelectAttributes(Instances data) throws Exception
Perform attribute selection on the supplied training instances.

Parameters:
data - the instances to select attributes from
Throws: Exception
if there is a problem during selection
 o 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.

Parameters:
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
outAttributes - index 0 will contain the array of selected attribute indices
train - the input instances
Returns:
the results of attribute selection as a String
Throws: Exception
if incorrect options are supplied
 o main
 public static void main(String args[])
Main method for testing this class.

Parameters:
args - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home