weka.classifiers.meta
Class FilteredClassifierExt

java.lang.Object
  extended by weka.classifiers.AbstractClassifier
      extended by weka.classifiers.SingleClassifierEnhancer
          extended by weka.classifiers.meta.FilteredClassifier
              extended by weka.classifiers.meta.FilteredClassifierExt
All Implemented Interfaces:
Serializable, Cloneable, weka.classifiers.Classifier, weka.classifiers.IntervalEstimator, weka.core.CapabilitiesHandler, weka.core.Drawable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.WeightedInstancesHandler

public class FilteredClassifierExt
extends weka.classifiers.meta.FilteredClassifier
implements weka.core.WeightedInstancesHandler, weka.classifiers.IntervalEstimator

Class for running an arbitrary classifier on data that has been passed through an arbitrary filter. Like the classifier, the structure of the filter is based exclusively on the training data and test instances will be processed by the filter without changing their structure.

In addition to the default FilteredClassifier, one can specify a range of attributes that are to be removed before applying the actual filter. Useful to remove ID attributes, without having to nest another FilteredClassifier.

The meta-classifier also 'pretends' to be able to:
- handle weighted instances
- produce confidence intervals
This will only lead to reasonable results, of course, if the base classifier supports this functionality.

Valid options are:

 -R <att list>
  The range of attributes to remove. 'first' and 'last' are
  accepted as well.
  (default: none)
 -F <filter specification>
  Full class name of filter to use, followed
  by filter options.
  eg: "weka.filters.unsupervised.attribute.Remove -V -R 1,2"
 -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.trees.J48)
 Options specific to classifier weka.classifiers.trees.J48:
 
 -U
  Use unpruned tree.
 -O
  Do not collapse tree.
 -C <pruning confidence>
  Set confidence threshold for pruning.
  (default 0.25)
 -M <minimum number of instances>
  Set minimum number of instances per leaf.
  (default 2)
 -R
  Use reduced error pruning.
 -N <number of folds>
  Set number of folds for reduced error
  pruning. One fold is used as pruning set.
  (default 3)
 -B
  Use binary splits only.
 -S
  Don't perform subtree raising.
 -L
  Do not clean up after the tree has been built.
 -A
  Laplace smoothing for predicted probabilities.
 -J
  Do not use MDL correction for info gain on numeric attributes.
 -Q <seed>
  Seed for random data shuffling (default 1).

Version:
$Revision: 4521 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  weka.filters.unsupervised.attribute.Remove m_Remove
          The additional remove filter.
 
Fields inherited from class weka.classifiers.meta.FilteredClassifier
m_Filter, m_FilteredInstances
 
Fields inherited from class weka.classifiers.SingleClassifierEnhancer
m_Classifier
 
Fields inherited from class weka.classifiers.AbstractClassifier
m_Debug
 
Fields inherited from interface weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE
 
Constructor Summary
FilteredClassifierExt()
           
 
Method Summary
 void buildClassifier(weka.core.Instances data)
          Build the classifier on the filtered data.
 double[] distributionForInstance(weka.core.Instance instance)
          Classifies a given instance after filtering.
protected  weka.core.Instance filter(weka.filters.Filter filter, weka.core.Instance instance)
          Filters the Instance through the specified filter.
protected  weka.core.Instance filter(weka.core.Instance instance)
          Filters the Instance through the remove filter if necessary.
protected  weka.core.Instances filter(weka.core.Instances data)
          Filters the dataset through the remove filter if necessary.
 weka.core.Capabilities getCapabilities()
          Returns default capabilities of the classifier.
 String[] getOptions()
          Gets the current settings of the Classifier.
 String getRemoveAttributeIndices()
          Returns the attributes indices that are removed before applying the actual filter.
 String getRevision()
          Returns the revision string.
 String globalInfo()
          Returns a string describing this classifier.
protected  boolean isRemoveUsed()
          Returns whether the Remove filter is used at all.
 Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(String[] args)
          Main method for running this classifier.
 double[][] predictIntervals(weka.core.Instance instance, double confidenceLevel)
          Returns an N * 2 array, where N is the number of prediction intervals.
 String removeAttributeIndicesTipText()
          Returns the tip text for this property.
 void setOptions(String[] options)
          Parses a given list of options.
 void setRemoveAttributeIndices(String value)
          Sets the attribute indices to remove before applying the actual filter.
 
Methods inherited from class weka.classifiers.meta.FilteredClassifier
defaultClassifierString, filterTipText, getFilter, getFilterSpec, graph, graphType, setFilter, toString
 
Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, getClassifier, getClassifierSpec, setClassifier
 
Methods inherited from class weka.classifiers.AbstractClassifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Remove

protected weka.filters.unsupervised.attribute.Remove m_Remove
The additional remove filter.

Constructor Detail

FilteredClassifierExt

public FilteredClassifierExt()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing this classifier.

Overrides:
globalInfo in class weka.classifiers.meta.FilteredClassifier
Returns:
a description of the classifier suitable for displaying in the explorer/experimenter gui

listOptions

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

Specified by:
listOptions in interface weka.core.OptionHandler
Overrides:
listOptions in class weka.classifiers.meta.FilteredClassifier
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:

 -R <att list>
  The range of attributes to remove. 'first' and 'last' are
  accepted as well.
  (default: none)
 -F <filter specification>
  Full class name of filter to use, followed
  by filter options.
  eg: "weka.filters.unsupervised.attribute.Remove -V -R 1,2"
 -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.trees.J48)
 Options specific to classifier weka.classifiers.trees.J48:
 
 -U
  Use unpruned tree.
 -O
  Do not collapse tree.
 -C <pruning confidence>
  Set confidence threshold for pruning.
  (default 0.25)
 -M <minimum number of instances>
  Set minimum number of instances per leaf.
  (default 2)
 -R
  Use reduced error pruning.
 -N <number of folds>
  Set number of folds for reduced error
  pruning. One fold is used as pruning set.
  (default 3)
 -B
  Use binary splits only.
 -S
  Don't perform subtree raising.
 -L
  Do not clean up after the tree has been built.
 -A
  Laplace smoothing for predicted probabilities.
 -J
  Do not use MDL correction for info gain on numeric attributes.
 -Q <seed>
  Seed for random data shuffling (default 1).

Specified by:
setOptions in interface weka.core.OptionHandler
Overrides:
setOptions in class weka.classifiers.meta.FilteredClassifier
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 weka.core.OptionHandler
Overrides:
getOptions in class weka.classifiers.meta.FilteredClassifier
Returns:
an array of strings suitable for passing to setOptions

removeAttributeIndicesTipText

public String removeAttributeIndicesTipText()
Returns the tip text for this property.

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

setRemoveAttributeIndices

public void setRemoveAttributeIndices(String value)
Sets the attribute indices to remove before applying the actual filter.

Parameters:
value - the attribute indices (1-based)

getRemoveAttributeIndices

public String getRemoveAttributeIndices()
Returns the attributes indices that are removed before applying the actual filter.

Returns:
the attribute indices (1-based)

isRemoveUsed

protected boolean isRemoveUsed()
Returns whether the Remove filter is used at all.

Returns:
true if the Remove filter is used

getCapabilities

public weka.core.Capabilities getCapabilities()
Returns default capabilities of the classifier.

Specified by:
getCapabilities in interface weka.classifiers.Classifier
Specified by:
getCapabilities in interface weka.core.CapabilitiesHandler
Overrides:
getCapabilities in class weka.classifiers.meta.FilteredClassifier
Returns:
the capabilities of this classifier

filter

protected weka.core.Instances filter(weka.core.Instances data)
                              throws Exception
Filters the dataset through the remove filter if necessary.

Parameters:
data - the data to filter
Returns:
the processed data
Throws:
Exception - if filtering fails
See Also:
m_Remove

buildClassifier

public void buildClassifier(weka.core.Instances data)
                     throws Exception
Build the classifier on the filtered data.

Specified by:
buildClassifier in interface weka.classifiers.Classifier
Overrides:
buildClassifier in class weka.classifiers.meta.FilteredClassifier
Parameters:
data - the training data
Throws:
Exception - if the classifier could not be built successfully

filter

protected weka.core.Instance filter(weka.filters.Filter filter,
                                    weka.core.Instance instance)
                             throws Exception
Filters the Instance through the specified filter.

Parameters:
filter - the filter to use
instance - the instance to filter
Returns:
the processed instance
Throws:
Exception - if filtering fails

filter

protected weka.core.Instance filter(weka.core.Instance instance)
                             throws Exception
Filters the Instance through the remove filter if necessary.

Parameters:
instance - the instance to filter
Returns:
the processed instance
Throws:
Exception - if filtering fails
See Also:
m_Remove

distributionForInstance

public double[] distributionForInstance(weka.core.Instance instance)
                                 throws Exception
Classifies a given instance after filtering.

Specified by:
distributionForInstance in interface weka.classifiers.Classifier
Overrides:
distributionForInstance in class weka.classifiers.meta.FilteredClassifier
Parameters:
instance - the instance to be classified
Returns:
the class distribution for the given instance
Throws:
Exception - if instance could not be classified successfully

predictIntervals

public double[][] predictIntervals(weka.core.Instance instance,
                                   double confidenceLevel)
                            throws Exception
Returns an N * 2 array, where N is the number of prediction intervals. In each row, the first element contains the lower boundary of the corresponding prediction interval and the second element the upper boundary.

Specified by:
predictIntervals in interface weka.classifiers.IntervalEstimator
Parameters:
instance - the instance to make the prediction for.
confidenceLevel - the percentage of cases that the interval should cover.
Returns:
an array of prediction intervals
Throws:
Exception - if the intervals can't be computed

getRevision

public String getRevision()
Returns the revision string.

Specified by:
getRevision in interface weka.core.RevisionHandler
Overrides:
getRevision in class weka.classifiers.meta.FilteredClassifier
Returns:
the revision

main

public static void main(String[] args)
Main method for running this classifier.

Parameters:
args - the parameters, use -h to display them


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.