public class CVParameterSelection extends RandomizableSingleClassifierEnhancer implements Drawable, Summarizable, TechnicalInformationHandler
@phdthesis{Kohavi1995, address = {Department of Computer Science, Stanford University}, author = {R. Kohavi}, school = {Stanford University}, title = {Wrappers for Performance Enhancement and Oblivious Decision Graphs}, year = {1995} }Valid options are:
-X <number of folds> Number of folds used for cross validation (default 10).
-P <classifier parameter> Classifier parameter options. eg: "N 1 5 10" Sets an optimisation parameter for the classifier with name -N, with lower bound 1, upper bound 5, and 10 optimisation steps. The upper bound may be the character 'A' or 'I' to substitute the number of attributes or instances in the training data, respectively. This parameter may be supplied more than once to optimise over several classifier options simultaneously.
-S <num> Random number seed. (default 1)
-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.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the consoleOptions after -- are passed to the designated sub-classifier.
Modifier and Type | Class and Description |
---|---|
protected class |
CVParameterSelection.CVParameter
A data structure to hold values associated with a single
cross-validation search parameter
|
Modifier and Type | Field and Description |
---|---|
protected String[] |
m_BestClassifierOptions
The set of all classifier options as determined by cross-validation
|
protected double |
m_BestPerformance
The cross-validated performance of the best options
|
protected String[] |
m_ClassifierOptions
The base classifier options (not including those being set
by cross-validation)
|
protected FastVector |
m_CVParams
The set of parameters to cross-validate over
|
protected String[] |
m_InitOptions
The set of all options at initialization time.
|
protected int |
m_NumAttributes
The number of attributes in the data
|
protected int |
m_NumFolds
The number of folds used in cross-validation
|
protected int |
m_TrainFoldSize
The number of instances in a training fold
|
m_Seed
m_Classifier
m_Debug
BayesNet, Newick, NOT_DRAWABLE, TREE
Constructor and Description |
---|
CVParameterSelection() |
Modifier and Type | Method and Description |
---|---|
void |
addCVParameter(String cvParam)
Adds a scheme parameter to the list of parameters to be set
by cross-validation
|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
protected String[] |
createOptions()
Create the options array to pass to the classifier.
|
String |
CVParametersTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Predicts the class distribution for the given test instance.
|
protected void |
findParamsByCrossValidation(int depth,
Instances trainData,
Random random)
Finds the best parameter combination.
|
String[] |
getBestClassifierOptions()
Returns (a copy of) the best options found for the classifier.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
String |
getCVParameter(int index)
Gets the scheme paramter with the given index.
|
Object[] |
getCVParameters()
Get method for CVParameters.
|
int |
getNumFolds()
Gets the number of folds for the cross-validation.
|
String[] |
getOptions()
Gets the current settings of the Classifier.
|
String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
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.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
String |
numFoldsTipText()
Returns the tip text for this property
|
void |
setCVParameters(Object[] params)
Set method for CVParameters.
|
void |
setNumFolds(int numFolds)
Sets the number of folds for the cross-validation.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
String |
toString()
Returns description of the cross-validated classifier.
|
String |
toSummaryString()
A concise description of the model.
|
getSeed, seedTipText, setSeed
classifierTipText, defaultClassifierString, getClassifier, getClassifierSpec, setClassifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
protected String[] m_ClassifierOptions
protected String[] m_BestClassifierOptions
protected String[] m_InitOptions
protected double m_BestPerformance
protected FastVector m_CVParams
protected int m_NumAttributes
protected int m_TrainFoldSize
protected int m_NumFolds
protected String[] createOptions()
protected void findParamsByCrossValidation(int depth, Instances trainData, Random random) throws Exception
depth
- the index of the parameter to be optimised at this leveltrainData
- the data the search is based onrandom
- a random number generatorException
- if an error occurspublic String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableSingleClassifierEnhancer
public void setOptions(String[] options) throws Exception
-X <number of folds> Number of folds used for cross validation (default 10).
-P <classifier parameter> Classifier parameter options. eg: "N 1 5 10" Sets an optimisation parameter for the classifier with name -N, with lower bound 1, upper bound 5, and 10 optimisation steps. The upper bound may be the character 'A' or 'I' to substitute the number of attributes or instances in the training data, respectively. This parameter may be supplied more than once to optimise over several classifier options simultaneously.
-S <num> Random number seed. (default 1)
-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.rules.ZeroR)
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the consoleOptions after -- are passed to the designated sub-classifier.
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[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableSingleClassifierEnhancer
public String[] getBestClassifierOptions()
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class SingleClassifierEnhancer
Capabilities
public void buildClassifier(Instances instances) throws Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training dataException
- if the classifier has not been generated successfullypublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in class Classifier
instance
- the instance to be classifiedException
- if an error occurred during the predictionpublic void addCVParameter(String cvParam) throws Exception
cvParam
- the string representation of a scheme parameter. The
format is: Exception
- if the parameter specifier is of the wrong formatpublic String getCVParameter(int index)
index
- the index for the parameterpublic String CVParametersTipText()
public Object[] getCVParameters()
public void setCVParameters(Object[] params) throws Exception
params
- the CVParameters to useException
- if the setting of the CVParameters failspublic String numFoldsTipText()
public int getNumFolds()
public void setNumFolds(int numFolds) throws Exception
numFolds
- the number of folds for the cross-validationException
- if parameter illegalpublic int graphType()
public String toString()
public String toSummaryString()
toSummaryString
in interface Summarizable
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier
public static void main(String[] argv)
argv
- the optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.