public class FilteredClassifier extends RandomizableSingleClassifierEnhancer implements Drawable, PartitionGenerator, IterativeClassifier, BatchPredictor, WeightedInstancesHandler, WeightedAttributesHandler
-F <filter specification> Full class name of filter to use, followed by filter options. default: "weka.filters.supervised.attribute.Discretize -R first-last -precision 6"
-W <classifier name> Full name of base classifier. (default: weka.classifiers.trees.J48)
-S num The random number seed to be used (default 1).-doNotCheckForModifiedClassAttribute
-output-debug-info
If set, classifier is run in debug mode and may output additional info to
the console.
-do-not-check-capabilities
If set, classifier capabilities are not checked before classifier is built
(use with caution).
-num-decimal-places
The number of decimal places for the output of numbers in the model.
-batch-size
The desired batch size for batch prediction.
Options specific to classifier weka.classifiers.trees.J48:
-U Use unpruned 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.
-S <seed> Seed for random data shuffling (default 1).
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_DoNotCheckForModifiedClassAttribute
Flag that can be set to true if class attribute is not to be checked for modifications by the filer.
|
protected Filter |
m_Filter
The filter
|
protected Instances |
m_FilteredInstances
The instance structure of the filtered instances
|
protected Reorder |
m_ReorderFiltered |
protected Reorder |
m_ReorderOriginal
If the attributes are resampled, we store the filter for this
|
m_Seedm_ClassifierBATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULTBayesNet, Newick, NOT_DRAWABLE, TREE| Constructor and Description |
|---|
FilteredClassifier()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
batchSizeTipText()
Tool tip text for this property
|
void |
buildClassifier(Instances data)
Build the classifier on the filtered data.
|
protected java.lang.String |
defaultClassifierString()
String describing default classifier.
|
protected java.lang.String |
defaultFilterString()
String describing default filter.
|
double[] |
distributionForInstance(Instance instance)
Classifies a given instance after filtering.
|
double[][] |
distributionsForInstances(Instances insts)
Batch scoring method.
|
void |
done()
Signal end of iterating, useful for any house-keeping/cleanup (If the base
classifier supports this.)
|
java.lang.String |
doNotCheckForModifiedClassAttributeTipText()
Returns the tip text for this property
|
protected Instance |
filterInstance(Instance instance)
Filters the instance so that it can subsequently be classified.
|
java.lang.String |
filterTipText()
Returns the tip text for this property
|
void |
generatePartition(Instances data)
Builds the classifier to generate a partition.
|
java.lang.String |
getBatchSize()
Gets the preferred batch size from the base learner if it implements
BatchPredictor.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDoNotCheckForModifiedClassAttribute()
Returns true if classifier checks whether class attribute has been modified by filter.
|
Filter |
getFilter()
Gets the filter used.
|
protected java.lang.String |
getFilterSpec()
Gets the filter specification string, which contains the class name of the
filter and any options to the filter
|
double[] |
getMembershipValues(Instance inst)
Computes an array that has a value for each element in the partition.
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
java.lang.String |
getRevision()
Returns the revision string.
|
java.lang.String |
globalInfo()
Returns a string describing this classifier
|
java.lang.String |
graph()
Returns graph describing the classifier (if possible).
|
int |
graphType()
Returns the type of graph this classifier represents.
|
boolean |
implementsMoreEfficientBatchPrediction()
Returns true if the base classifier implements BatchPredictor and is able
to generate batch predictions efficiently
|
void |
initializeClassifier(Instances data)
Initializes an iterative classifier.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
boolean |
next()
Performs one iteration.
|
int |
numElements()
Returns the number of elements in the partition.
|
protected Instances |
resampleAttributes(Instances data,
boolean original,
java.util.Random random)
Resamples set of attributes.
|
void |
setBatchSize(java.lang.String size)
Set the batch size to use.
|
void |
setDoNotCheckForModifiedClassAttribute(boolean flag)
Use this method to determine whether classifier checks whether class attribute has been modified by filter.
|
void |
setFilter(Filter filter)
Sets the filter
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
protected Instances |
setUp(Instances data,
java.util.Random random)
Sets up the filter and runs checks.
|
java.lang.String |
toString()
Output a representation of this classifier
|
getSeed, seedTipText, setSeedclassifierTipText, defaultClassifierOptions, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifierclassifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclassifyInstanceprotected Filter m_Filter
protected Instances m_FilteredInstances
protected boolean m_DoNotCheckForModifiedClassAttribute
protected Reorder m_ReorderOriginal
protected Reorder m_ReorderFiltered
public java.lang.String globalInfo()
protected java.lang.String defaultClassifierString()
defaultClassifierString in class SingleClassifierEnhancerprotected java.lang.String defaultFilterString()
public int graphType()
public java.lang.String graph()
throws java.lang.Exception
public void generatePartition(Instances data) throws java.lang.Exception
generatePartition in interface PartitionGeneratorjava.lang.Exceptionpublic double[] getMembershipValues(Instance inst) throws java.lang.Exception
getMembershipValues in interface PartitionGeneratorjava.lang.Exceptionpublic int numElements()
throws java.lang.Exception
numElements in interface PartitionGeneratorjava.lang.Exceptionpublic void initializeClassifier(Instances data) throws java.lang.Exception
initializeClassifier in interface IterativeClassifierdata - the instances to be used in inductionjava.lang.Exception - if the model cannot be initializedpublic boolean next()
throws java.lang.Exception
next in interface IterativeClassifierjava.lang.Exception - if this iteration fails for unexpected reasonspublic void done()
throws java.lang.Exception
done in interface IterativeClassifierjava.lang.Exception - if cleanup failspublic java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class RandomizableSingleClassifierEnhancerpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
-F <filter specification> Full class name of filter to use, followed by filter options. default: "weka.filters.supervised.attribute.Discretize -R first-last -precision 6"
-W <classifier name> Full name of base classifier. (default: weka.classifiers.trees.J48)
-S num The random number seed to be used.-doNotCheckForModifiedClassAttribute
-output-debug-info
If set, classifier is run in debug mode and may output additional info to
the console.
-do-not-check-capabilities
If set, classifier capabilities are not checked before classifier is built
(use with caution).
-num-decimal-laces
The number of decimal places for the output of numbers in the model.
-batch-size
The desired batch size for batch prediction.
Options specific to classifier weka.classifiers.trees.J48:
-U Use unpruned 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.
-Q <seed> Seed for random data shuffling (default 1).
setOptions in interface OptionHandlersetOptions in class RandomizableSingleClassifierEnhanceroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedpublic java.lang.String doNotCheckForModifiedClassAttributeTipText()
public boolean getDoNotCheckForModifiedClassAttribute()
public void setDoNotCheckForModifiedClassAttribute(boolean flag)
public java.lang.String[] getOptions()
getOptions in interface OptionHandlergetOptions in class RandomizableSingleClassifierEnhancerpublic java.lang.String filterTipText()
public void setFilter(Filter filter)
filter - the filter with all options set.public Filter getFilter()
protected java.lang.String getFilterSpec()
public Capabilities getCapabilities()
getCapabilities in interface ClassifiergetCapabilities in interface CapabilitiesHandlergetCapabilities in class SingleClassifierEnhancerCapabilitiesprotected Instances setUp(Instances data, java.util.Random random) throws java.lang.Exception
java.lang.Exceptionprotected Instances resampleAttributes(Instances data, boolean original, java.util.Random random) throws java.lang.Exception
data - the data to be filteredoriginal - whether the original or the filtered data are to be resampledrandom - the random number generator to usejava.lang.Exceptionpublic void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier in interface Classifierdata - the training datajava.lang.Exception - if the classifier could not be built successfullyprotected Instance filterInstance(Instance instance) throws java.lang.Exception
java.lang.Exceptionpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to be classifiedjava.lang.Exception - if instance could not be classified successfullypublic java.lang.String batchSizeTipText()
batchSizeTipText in class AbstractClassifierpublic void setBatchSize(java.lang.String size)
setBatchSize in interface BatchPredictorsetBatchSize in class AbstractClassifiersize - the batch size to usepublic java.lang.String getBatchSize()
getBatchSize in interface BatchPredictorgetBatchSize in class AbstractClassifierpublic double[][] distributionsForInstances(Instances insts) throws java.lang.Exception
distributionsForInstances in interface BatchPredictordistributionsForInstances in class AbstractClassifierinsts - the instances to get predictions forjava.lang.Exception - if a problem occurspublic boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction in interface BatchPredictorimplementsMoreEfficientBatchPrediction in class AbstractClassifierpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifierpublic static void main(java.lang.String[] argv)
argv - should contain the following arguments: -t training file [-T
test file] [-c class index]