Package weka.classifiers.meta
Class IterativeClassifierOptimizer
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.RandomizableClassifier
weka.classifiers.meta.IterativeClassifierOptimizer
- All Implemented Interfaces:
Serializable,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:
-
Field Summary
FieldsFields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances data) Builds the classifier.Returns the tip text for this propertydouble[]Returns the class distribution for an instance.Returns an enumeration of the additional measure namesReturns the tip text for this propertyReturns default capabilities of the base classifier.intGet the class value index to useGet the evaluation metric to useGet the classifier used as the base learner.intGet the value of LookAheadIterations.doublegetMeasure(String additionalMeasureName) Returns the value of the named measureintGet the value of NumFolds.intGet the value of NumRuns.intGets the number of threads.String[]Gets the current settings of the Classifier.intGets the number of threads.booleanGet the value of PreserveOrderInPercentageSplitEvaluation.Returns the revision string.doubleGet the value of SplitPercentage.intGet the value of StepSize.booleanGet the value of UseAverage.Returns a string describing classifierReturns the tip text for this propertyReturns an enumeration describing the available options.Returns the tip text for this propertystatic voidMain method for testing this class.doubleReturns the best number of iterationsdoubleReturns the measure for the best modelReturns the tip text for this propertyReturns the tip text for this propertyReturns 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(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.Returns the tip text for this propertyReturns the tip text for this propertytoString()Returns a string describing the classifier.Returns the tip text for this propertyMethods inherited from class weka.classifiers.RandomizableClassifier
getSeed, seedTipText, setSeedMethods 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 Details
-
TAGS_EVAL
-
-
Constructor Details
-
IterativeClassifierOptimizer
public IterativeClassifierOptimizer()
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
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
- 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
- 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
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
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
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
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
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
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
Builds the classifier.- Specified by:
buildClassifierin interfaceClassifier- Parameters:
data- set of instances serving as training data- Throws:
Exception- if the classifier has not been generated successfully
-
distributionForInstance
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:
Exception- if distribution could not be computed successfully
-
toString
Returns a string describing the classifier. -
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classRandomizableClassifier- Returns:
- an enumeration of all the available options.
-
setOptions
Parses 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:
Exception- if an option is not supported
-
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
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setEvaluationMetric
Set the evaluation metric to use- Parameters:
metric- the metric to use
-
getEvaluationMetric
Get the evaluation metric to use- Returns:
- the evaluation metric to use
-
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
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
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:
-
setIterativeClassifier
Set the base learner.- Parameters:
newIterativeClassifier- the classifier to use.
-
getIterativeClassifier
Get the classifier used as the base learner.- Returns:
- the classifier used as the classifier
-
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
Returns an enumeration of the additional measure names- Specified by:
enumerateMeasuresin interfaceAdditionalMeasureProducer- Returns:
- an enumeration of the measure names
-
getMeasure
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:
IllegalArgumentException- if the named measure is not supported
-
main
Main method for testing this class.- Parameters:
argv- the options
-