weka.classifiers
Class AttributeSelectedClassifier

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--weka.classifiers.DistributionClassifier
              |
              +--weka.classifiers.AttributeSelectedClassifier
All Implemented Interfaces:
AdditionalMeasureProducer, Cloneable, OptionHandler, Serializable

public class AttributeSelectedClassifier
extends DistributionClassifier
implements OptionHandler, AdditionalMeasureProducer

Class for running an arbitrary classifier on data that has been reduced through attribute selection.

Valid options from the command line are:

-B classifierstring
Classifierstring should contain the full class name of a classifier followed by options to the classifier. (required).

-E evaluatorstring
Evaluatorstring should contain the full class name of an attribute evaluator followed by any options. (required).

-S searchstring
Searchstring should contain the full class name of a search method followed by any options. (required).

Version:
$Revision: 1.7 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
protected  AttributeSelection m_AttributeSelection
          The attribute selection object
protected  Classifier m_Classifier
          The classifier
protected  ASEvaluation m_Evaluator
          The attribute evaluator to use
protected  double m_numAttributesSelected
          The number of attributes selected by the attribute selection phase
protected  int m_numClasses
          The number of class vals in the training data (1 if class is numeric)
protected  Instances m_ReducedHeader
          The header of the dimensionally reduced data
protected  ASSearch m_Search
          The search method to use
protected  double m_selectionTime
          The time taken to select attributes in milliseconds
protected  double m_totalTime
          The time taken to select attributes AND build the classifier
 
Constructor Summary
AttributeSelectedClassifier()
           
 
Method Summary
 void buildClassifier(Instances data)
          Build the classifier on the dimensionally reduced data.
 String classifierTipText()
          Returns the tip text for this property
 double[] distributionForInstance(Instance instance)
          Classifies a given instance after attribute selection
 Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 String evaluatorTipText()
          Returns the tip text for this property
 Classifier getClassifier()
          Gets the classifier used.
protected  String getClassifierSpec()
          Gets the classifier specification string, which contains the class name of the classifier and any options to the classifier
 ASEvaluation getEvaluator()
          Gets the attribute evaluator used
protected  String getEvaluatorSpec()
          Gets the evaluator specification string, which contains the class name of the attribute evaluator and any options to it
 double getMeasure(String additionalMeasureName)
          Returns the value of the named measure
 String[] getOptions()
          Gets the current settings of the Classifier.
 ASSearch getSearch()
          Gets the search method used
protected  String getSearchSpec()
          Gets the search specification string, which contains the class name of the search method and any options to it
 String globalInfo()
          Returns a string describing this search method
 Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(String[] argv)
          Main method for testing this class.
 double measureNumAttributesSelected()
          Additional measure --- number of attributes selected
 double measureSelectionTime()
          Additional measure --- time taken (milliseconds) to select the attributes
 double measureTime()
          Additional measure --- time taken (milliseconds) to select attributes and build the classifier
 String searchTipText()
          Returns the tip text for this property
 void setClassifier(Classifier classifier)
          Sets the classifier
 void setEvaluator(ASEvaluation evaluator)
          Sets the attribute evaluator
 void setOptions(String[] options)
          Parses a given list of options.
 void setSearch(ASSearch search)
          Sets the search method
 String toString()
          Output a representation of this classifier
 
Methods inherited from class weka.classifiers.DistributionClassifier
classifyInstance
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Classifier

protected Classifier m_Classifier
The classifier


m_AttributeSelection

protected AttributeSelection m_AttributeSelection
The attribute selection object


m_Evaluator

protected ASEvaluation m_Evaluator
The attribute evaluator to use


m_Search

protected ASSearch m_Search
The search method to use


m_ReducedHeader

protected Instances m_ReducedHeader
The header of the dimensionally reduced data


m_numClasses

protected int m_numClasses
The number of class vals in the training data (1 if class is numeric)


m_numAttributesSelected

protected double m_numAttributesSelected
The number of attributes selected by the attribute selection phase


m_selectionTime

protected double m_selectionTime
The time taken to select attributes in milliseconds


m_totalTime

protected double m_totalTime
The time taken to select attributes AND build the classifier

Constructor Detail

AttributeSelectedClassifier

public AttributeSelectedClassifier()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing this search method

Returns:
a description of the search method suitable for displaying in the explorer/experimenter gui

listOptions

public Enumeration listOptions()
Returns an enumeration describing the available options

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options

setOptions

public void setOptions(String[] options)
                throws Exception
Parses a given list of options. Valid options are:

-B classifierstring
Classifierstring should contain the full class name of a classifier followed by options to the classifier. (required).

-E evaluatorstring
Evaluatorstring should contain the full class name of an attribute evaluator followed by any options. (required).

-S searchstring
Searchstring should contain the full class name of a search method followed by any options. (required).

Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
Exception - if an option is not supported

getOptions

public String[] getOptions()
Gets the current settings of the Classifier.

Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions

classifierTipText

public String classifierTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setClassifier

public void setClassifier(Classifier classifier)
Sets the classifier

Parameters:
classifier - the classifier with all options set.

getClassifier

public Classifier getClassifier()
Gets the classifier used.

Returns:
the classifier

getClassifierSpec

protected String getClassifierSpec()
Gets the classifier specification string, which contains the class name of the classifier and any options to the classifier

Returns:
the classifier string.

evaluatorTipText

public String evaluatorTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setEvaluator

public void setEvaluator(ASEvaluation evaluator)
Sets the attribute evaluator

Parameters:
evaluator - the evaluator with all options set.

getEvaluator

public ASEvaluation getEvaluator()
Gets the attribute evaluator used

Returns:
the attribute evaluator

getEvaluatorSpec

protected String getEvaluatorSpec()
Gets the evaluator specification string, which contains the class name of the attribute evaluator and any options to it

Returns:
the evaluator string.

searchTipText

public String searchTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setSearch

public void setSearch(ASSearch search)
Sets the search method

Parameters:
search - the search method with all options set.

getSearch

public ASSearch getSearch()
Gets the search method used

Returns:
the search method

getSearchSpec

protected String getSearchSpec()
Gets the search specification string, which contains the class name of the search method and any options to it

Returns:
the search string.

buildClassifier

public void buildClassifier(Instances data)
                     throws Exception
Build the classifier on the dimensionally reduced data.

Specified by:
buildClassifier in class Classifier
Parameters:
data - the training data
Throws:
Exception - if the classifier could not be built successfully

distributionForInstance

public double[] distributionForInstance(Instance instance)
                                 throws Exception
Classifies a given instance after attribute selection

Specified by:
distributionForInstance in class DistributionClassifier
Parameters:
instance - the instance to be classified
Returns:
an array containing the estimated membership probabilities of the test instance in each class (this should sum to at most 1)
Throws:
Exception - if instance could not be classified successfully

toString

public String toString()
Output a representation of this classifier

Overrides:
toString in class Object

measureNumAttributesSelected

public double measureNumAttributesSelected()
Additional measure --- number of attributes selected

Returns:
the number of attributes selected

measureSelectionTime

public double measureSelectionTime()
Additional measure --- time taken (milliseconds) to select the attributes

Returns:
the time taken to select attributes

measureTime

public double measureTime()
Additional measure --- time taken (milliseconds) to select attributes and build the classifier

Returns:
the total time (select attributes + build classifier)

enumerateMeasures

public Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(String additionalMeasureName)
Returns the value of the named measure

Specified by:
getMeasure in interface AdditionalMeasureProducer
Parameters:
additionalMeasureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
IllegalArgumentException - if the named measure is not supported

main

public static void main(String[] argv)
Main method for testing this class.

Parameters:
argv - should contain the following arguments: -t training file [-T test file] [-c class index]