Package weka.classifiers.meta
Class IterativeClassifierOptimizer
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.RandomizableClassifier
-
- weka.classifiers.meta.IterativeClassifierOptimizer
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Classifier,AdditionalMeasureProducer,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,Randomizable,RevisionHandler
public class IterativeClassifierOptimizer extends RandomizableClassifier implements AdditionalMeasureProducer
Chooses the best number of iterations for an IterativeClassifier such as LogitBoost using cross-validation or a percentage split evaluation. Optimizes the number of iterations of the given iterative classifier using cross-validation or a percentage split evaluation. Valid options are:-A If set, average estimate is used rather than one estimate from pooled predictions.
-L <num> The number of iterations to look ahead for to find a better optimum. (default 50)
-P <int> The size of the thread pool, for example, the number of cores in the CPU. (default 1)
-E <int> The number of threads to use, which should be >= size of thread pool. (default 1)
-I <num> Step size for the evaluation, if evaluation is time consuming. (default 1)
-F <num> Number of folds for cross-validation. (default 10)
-R <num> Number of runs for cross-validation. (default 1)
-W Full name of base classifier. (default: weka.classifiers.meta.LogitBoost)
-metric <name> Evaluation metric to optimise (default rmse). Available metrics: correct,incorrect,kappa,total cost,average cost,kb relative,kb information, correlation,complexity 0,complexity scheme,complexity improvement, mae,rmse,rae,rrse,coverage,region size,tp rate,fp rate,precision,recall, f-measure,mcc,roc area,prc area
-class-value-index <0-based index> Class value index to optimise. Ignored for all but information-retrieval type metrics (such as roc area). If unspecified (or a negative value is supplied), and an information-retrieval metric is specified, then the class-weighted average metric used. (default -1)
-S <num> Random number seed. (default 1)
-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).
Options specific to classifier weka.classifiers.meta.LogitBoost:
-Q Use resampling instead of reweighting for boosting.
-P <percent> Percentage of weight mass to base training on. (default 100, reduce to around 90 speed up)
-L <num> Threshold on the improvement of the likelihood. (default -Double.MAX_VALUE)
-H <num> Shrinkage parameter. (default 1)
-Z <num> Z max threshold for responses. (default 3)
-O <int> The size of the thread pool, for example, the number of cores in the CPU. (default 1)
-E <int> The number of threads to use for batch prediction, which should be >= size of thread pool. (default 1)
-S <num> Random number seed. (default 1)
-I <num> Number of iterations. (default 10)
-percentage <num> The percentage of data to be used for training (if 0, k-fold cross-validation is used). (default 0)
-order Whether to preserve order when a percentage split evaluation is performed.
-W Full name of base classifier. (default: weka.classifiers.trees.DecisionStump)
-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).
Options specific to classifier weka.classifiers.trees.DecisionStump:
-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).
- Version:
- $Revision: 10141 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Tag[]TAGS_EVAL-
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description IterativeClassifierOptimizer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(Instances data)Builds the classifier.java.lang.StringclassValueIndexTipText()Returns the tip text for this propertydouble[]distributionForInstance(Instance inst)Returns the class distribution for an instance.java.util.Enumeration<java.lang.String>enumerateMeasures()Returns an enumeration of the additional measure namesjava.lang.StringevaluationMetricTipText()Returns the tip text for this propertyCapabilitiesgetCapabilities()Returns default capabilities of the base classifier.intgetClassValueIndex()Get the class value index to useSelectedTaggetEvaluationMetric()Get the evaluation metric to useIterativeClassifiergetIterativeClassifier()Get the classifier used as the base learner.intgetLookAheadIterations()Get the value of LookAheadIterations.doublegetMeasure(java.lang.String additionalMeasureName)Returns the value of the named measureintgetNumFolds()Get the value of NumFolds.intgetNumRuns()Get the value of NumRuns.intgetNumThreads()Gets the number of threads.java.lang.String[]getOptions()Gets the current settings of the Classifier.intgetPoolSize()Gets the number of threads.booleangetPreserveOrderInPercentageSplitEvaluation()Get the value of PreserveOrderInPercentageSplitEvaluation.java.lang.StringgetRevision()Returns the revision string.doublegetSplitPercentage()Get the value of SplitPercentage.intgetStepSize()Get the value of StepSize.booleangetUseAverage()Get the value of UseAverage.java.lang.StringglobalInfo()Returns a string describing classifierjava.lang.StringiterativeClassifierTipText()Returns the tip text for this propertyjava.util.Enumeration<Option>listOptions()Returns an enumeration describing the available options.java.lang.StringlookAheadIterationsTipText()Returns the tip text for this propertystatic voidmain(java.lang.String[] argv)Main method for testing this class.doublemeasureBestNumIts()Returns the best number of iterationsdoublemeasureBestVal()Returns the measure for the best modeljava.lang.StringnumFoldsTipText()Returns the tip text for this propertyjava.lang.StringnumRunsTipText()Returns the tip text for this propertyjava.lang.StringnumThreadsTipText()java.lang.StringpoolSizeTipText()java.lang.StringpreserveOrderInPercentageSplitEvaluationTipText()Returns the tip text for this propertyvoidsetClassValueIndex(int i)Set the class value index to usevoidsetEvaluationMetric(SelectedTag metric)Set the evaluation metric to usevoidsetIterativeClassifier(IterativeClassifier newIterativeClassifier)Set the base learner.voidsetLookAheadIterations(int newLookAheadIterations)Set the value of LookAheadIterations.voidsetNumFolds(int newNumFolds)Set the value of NumFolds.voidsetNumRuns(int newNumRuns)Set the value of NumRuns.voidsetNumThreads(int nT)Sets the number of threadsvoidsetOptions(java.lang.String[] options)Parses a given list of options.voidsetPoolSize(int nT)Sets the number of threadsvoidsetPreserveOrderInPercentageSplitEvaluation(boolean newPreserveOrderInPercentageSplitEvaluation)Set the value of PreserveOrderInPercentageSplitEvaluation.voidsetSplitPercentage(double newSplitPercentage)Set the value of SplitPercentage.voidsetStepSize(int newStepSize)Set the value of StepSize.voidsetUseAverage(boolean newUseAverage)Set the value of UseAverage.java.lang.StringsplitPercentageTipText()Returns the tip text for this propertyjava.lang.StringstepSizeTipText()Returns the tip text for this propertyjava.lang.StringtoString()Returns a string describing the classifier.java.lang.StringuseAverageTipText()Returns the tip text for this property-
Methods inherited from class weka.classifiers.RandomizableClassifier
getSeed, seedTipText, setSeed
-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
TAGS_EVAL
public static Tag[] TAGS_EVAL
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
useAverageTipText
public java.lang.String useAverageTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getUseAverage
public boolean getUseAverage()
Get the value of UseAverage.- Returns:
- Value of UseAverage.
-
setUseAverage
public void setUseAverage(boolean newUseAverage)
Set the value of UseAverage.- Parameters:
newUseAverage- Value to assign to UseAverage.
-
numThreadsTipText
public java.lang.String numThreadsTipText()
- Returns:
- a string to describe the option
-
getNumThreads
public int getNumThreads()
Gets the number of threads.
-
setNumThreads
public void setNumThreads(int nT)
Sets the number of threads
-
poolSizeTipText
public java.lang.String poolSizeTipText()
- Returns:
- a string to describe the option
-
getPoolSize
public int getPoolSize()
Gets the number of threads.
-
setPoolSize
public void setPoolSize(int nT)
Sets the number of threads
-
stepSizeTipText
public java.lang.String stepSizeTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getStepSize
public int getStepSize()
Get the value of StepSize.- Returns:
- Value of StepSize.
-
setStepSize
public void setStepSize(int newStepSize)
Set the value of StepSize.- Parameters:
newStepSize- Value to assign to StepSize.
-
numRunsTipText
public java.lang.String numRunsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumRuns
public int getNumRuns()
Get the value of NumRuns.- Returns:
- Value of NumRuns.
-
setNumRuns
public void setNumRuns(int newNumRuns)
Set the value of NumRuns.- Parameters:
newNumRuns- Value to assign to NumRuns.
-
numFoldsTipText
public java.lang.String numFoldsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumFolds
public int getNumFolds()
Get the value of NumFolds.- Returns:
- Value of NumFolds.
-
setNumFolds
public void setNumFolds(int newNumFolds)
Set the value of NumFolds.- Parameters:
newNumFolds- Value to assign to NumFolds.
-
lookAheadIterationsTipText
public java.lang.String lookAheadIterationsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getLookAheadIterations
public int getLookAheadIterations()
Get the value of LookAheadIterations.- Returns:
- Value of LookAheadIterations.
-
setLookAheadIterations
public void setLookAheadIterations(int newLookAheadIterations)
Set the value of LookAheadIterations.- Parameters:
newLookAheadIterations- Value to assign to LookAheadIterations.
-
splitPercentageTipText
public java.lang.String splitPercentageTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSplitPercentage
public double getSplitPercentage()
Get the value of SplitPercentage.- Returns:
- Value of SplitPercentage.
-
setSplitPercentage
public void setSplitPercentage(double newSplitPercentage)
Set the value of SplitPercentage.- Parameters:
newSplitPercentage- Value to assign to SplitPercentage.
-
preserveOrderInPercentageSplitEvaluationTipText
public java.lang.String preserveOrderInPercentageSplitEvaluationTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getPreserveOrderInPercentageSplitEvaluation
public boolean getPreserveOrderInPercentageSplitEvaluation()
Get the value of PreserveOrderInPercentageSplitEvaluation.- Returns:
- Value of PreserveOrderInPercentageSplitEvaluation.
-
setPreserveOrderInPercentageSplitEvaluation
public void setPreserveOrderInPercentageSplitEvaluation(boolean newPreserveOrderInPercentageSplitEvaluation)
Set the value of PreserveOrderInPercentageSplitEvaluation.- Parameters:
newPreserveOrderInPercentageSplitEvaluation- Value to assign to PreserveOrderInPercentageSplitEvaluation.
-
buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
Builds the classifier.- Specified by:
buildClassifierin interfaceClassifier- Parameters:
data- set of instances serving as training data- Throws:
java.lang.Exception- if the classifier has not been generated successfully
-
distributionForInstance
public double[] distributionForInstance(Instance inst) throws java.lang.Exception
Returns the class distribution for an instance.- Specified by:
distributionForInstancein interfaceClassifier- Overrides:
distributionForInstancein classAbstractClassifier- Parameters:
inst- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
- Throws:
java.lang.Exception- if distribution could not be computed successfully
-
toString
public java.lang.String toString()
Returns a string describing the classifier.- Overrides:
toStringin classjava.lang.Object
-
listOptions
public java.util.Enumeration<Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classRandomizableClassifier- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options. Options after -- are passed to the designated classifier.- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classRandomizableClassifier- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the Classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classRandomizableClassifier- Returns:
- an array of strings suitable for passing to setOptions
-
evaluationMetricTipText
public java.lang.String evaluationMetricTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setEvaluationMetric
public void setEvaluationMetric(SelectedTag metric)
Set the evaluation metric to use- Parameters:
metric- the metric to use
-
getEvaluationMetric
public SelectedTag getEvaluationMetric()
Get the evaluation metric to use- Returns:
- the evaluation metric to use
-
classValueIndexTipText
public java.lang.String classValueIndexTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setClassValueIndex
public void setClassValueIndex(int i)
Set the class value index to use- Parameters:
i- the class value index to use
-
getClassValueIndex
public int getClassValueIndex()
Get the class value index to use- Returns:
- the class value index to use
-
iterativeClassifierTipText
public java.lang.String iterativeClassifierTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCapabilities
public Capabilities getCapabilities()
Returns default capabilities of the base classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClassifier- Overrides:
getCapabilitiesin classAbstractClassifier- Returns:
- the capabilities of the base classifier
- See Also:
Capabilities
-
setIterativeClassifier
public void setIterativeClassifier(IterativeClassifier newIterativeClassifier)
Set the base learner.- Parameters:
newIterativeClassifier- the classifier to use.
-
getIterativeClassifier
public IterativeClassifier getIterativeClassifier()
Get the classifier used as the base learner.- Returns:
- the classifier used as the classifier
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
measureBestNumIts
public double measureBestNumIts()
Returns the best number of iterations- Returns:
- the best number of iterations
-
measureBestVal
public double measureBestVal()
Returns the measure for the best model- Returns:
- the number of leaves
-
enumerateMeasures
public java.util.Enumeration<java.lang.String> enumerateMeasures()
Returns an enumeration of the additional measure names- Specified by:
enumerateMeasuresin interfaceAdditionalMeasureProducer- Returns:
- an enumeration of the measure names
-
getMeasure
public double getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure- Specified by:
getMeasurein interfaceAdditionalMeasureProducer- Parameters:
additionalMeasureName- the name of the measure to query for its value- Returns:
- the value of the named measure
- Throws:
java.lang.IllegalArgumentException- if the named measure is not supported
-
main
public static void main(java.lang.String[] argv)
Main method for testing this class.- Parameters:
argv- the options
-
-