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).
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
BayesNet, Newick, NOT_DRAWABLE, TREE
Constructor and Description |
---|
FilteredClassifier()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
batchSizeTipText()
Tool tip text for this property
|
void |
buildClassifier(Instances data)
Build the classifier on the filtered data.
|
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.)
|
String |
doNotCheckForModifiedClassAttributeTipText()
Returns the tip text for this property
|
String |
filterTipText()
Returns the tip text for this property
|
void |
generatePartition(Instances data)
Builds the classifier to generate a partition.
|
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.
|
double[] |
getMembershipValues(Instance inst)
Computes an array that has a value for each element in the partition.
|
String[] |
getOptions()
Gets the current settings of the Classifier.
|
boolean |
getResume()
Returns true if the model is to be finalized (or has been finalized) after
training.
|
String |
getRevision()
Returns the revision string.
|
String |
globalInfo()
Returns a string describing this classifier
|
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.
|
Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
boolean |
next()
Performs one iteration.
|
int |
numElements()
Returns the number of elements in the partition.
|
String |
resumeTipText()
Tool tip text for finalize property
|
void |
setBatchSize(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(String[] options)
Parses a given list of options.
|
void |
setResume(boolean resume)
If called with argument true, then the next time done() is called the model is effectively
"frozen" and no further iterations can be performed
|
String |
toString()
Output a representation of this classifier
|
getSeed, seedTipText, setSeed
classifierTipText, getClassifier, postExecution, preExecution, setClassifier
classifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
classifyInstance
makeCopy
public String globalInfo()
public int graphType()
public void generatePartition(Instances data) throws Exception
generatePartition
in interface PartitionGenerator
Exception
public double[] getMembershipValues(Instance inst) throws Exception
getMembershipValues
in interface PartitionGenerator
Exception
public int numElements() throws Exception
numElements
in interface PartitionGenerator
Exception
public void initializeClassifier(Instances data) throws Exception
initializeClassifier
in interface IterativeClassifier
data
- the instances to be used in inductionException
- if the model cannot be initializedpublic boolean next() throws Exception
next
in interface IterativeClassifier
Exception
- if this iteration fails for unexpected reasonspublic void done() throws Exception
done
in interface IterativeClassifier
Exception
- if cleanup failspublic String resumeTipText()
public void setResume(boolean resume) throws Exception
setResume
in interface IterativeClassifier
resume
- true if the model is to be finalized after performing iterationsException
- if finalization cannot be setpublic boolean getResume()
getResume
in interface IterativeClassifier
public Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableSingleClassifierEnhancer
public void setOptions(String[] options) throws 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 OptionHandler
setOptions
in class RandomizableSingleClassifierEnhancer
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String doNotCheckForModifiedClassAttributeTipText()
public boolean getDoNotCheckForModifiedClassAttribute()
public void setDoNotCheckForModifiedClassAttribute(boolean flag)
public String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableSingleClassifierEnhancer
public String filterTipText()
public void setFilter(Filter filter)
filter
- the filter with all options set.public Filter getFilter()
public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class SingleClassifierEnhancer
Capabilities
public void buildClassifier(Instances data) throws Exception
buildClassifier
in interface Classifier
data
- the training dataException
- if the classifier could not be built successfullypublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedException
- if instance could not be classified successfullypublic String batchSizeTipText()
batchSizeTipText
in class AbstractClassifier
public void setBatchSize(String size)
setBatchSize
in interface BatchPredictor
setBatchSize
in class AbstractClassifier
size
- the batch size to usepublic String getBatchSize()
getBatchSize
in interface BatchPredictor
getBatchSize
in class AbstractClassifier
public double[][] distributionsForInstances(Instances insts) throws Exception
distributionsForInstances
in interface BatchPredictor
distributionsForInstances
in class AbstractClassifier
insts
- the instances to get predictions forException
- if a problem occurspublic boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction
in interface BatchPredictor
implementsMoreEfficientBatchPrediction
in class AbstractClassifier
public String toString()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(String[] argv)
argv
- should contain the following arguments: -t training file [-T
test file] [-c class index]Copyright © 2020 University of Waikato, Hamilton, NZ. All rights reserved.