public class Experiment extends Object implements Serializable, OptionHandler, RevisionHandler
-L <num> The lower run number to start the experiment from. (default 1)
-U <num> The upper run number to end the experiment at (inclusive). (default 10)
-T <arff file> The dataset to run the experiment on. (required, may be specified multiple times)
-P <class name> The full class name of a ResultProducer (required). eg: weka.experiment.RandomSplitResultProducer
-D <class name> The full class name of a ResultListener (required). eg: weka.experiment.CSVResultListener
-N <string> A string containing any notes about the experiment. (default none)
Options specific to result producer weka.experiment.RandomSplitResultProducer:
-P <percent> The percentage of instances to use for training. (default 66)
-D Save raw split evaluator output.
-O <file/directory name/path> The filename where raw output will be stored. If a directory name is specified then then individual outputs will be gzipped, otherwise all output will be zipped to the named file. Use in conjuction with -D. (default splitEvalutorOut.zip)
-W <class name> The full class name of a SplitEvaluator. eg: weka.experiment.ClassifierSplitEvaluator
-R Set when data is not to be randomized and the data sets' size. Is not to be determined via probabilistic rounding.
Options specific to split evaluator weka.experiment.ClassifierSplitEvaluator:
-W <class name> The full class name of the classifier. eg: weka.classifiers.bayes.NaiveBayes
-C <index> The index of the class for which IR statistics are to be output. (default 1)
-I <index> The index of an attribute to output in the results. This attribute should identify an instance in order to know which instances are in the test set of a cross validation. if 0 no output (default 0).
-P Add target and prediction columns to the result for each fold.
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the consoleAll options after -- will be passed to the result producer.
Modifier and Type | Field and Description |
---|---|
static String |
FILE_EXTENSION
The filename extension that should be used for experiment files
|
protected String[] |
m_AdditionalMeasures
Method names of additional measures of objects contained in the
custom property iterator.
|
protected boolean |
m_AdvanceDataSetFirst
If true an experiment will advance the current data set befor
any custom itererator
|
protected boolean |
m_ClassFirst
True if the class attribute is the first attribute for all
datasets involved in this experiment.
|
protected Instances |
m_CurrentInstances
The dataset currently being used
|
protected int |
m_CurrentProperty
The custom property value that has actually been set
|
protected int |
m_DatasetNumber
The current dataset number when the experiment is running
|
protected DefaultListModel |
m_Datasets
An array of dataset files
|
protected boolean |
m_Finished
True if the experiment has finished running
|
protected String |
m_Notes
User notes about the experiment
|
protected Object |
m_PropertyArray
The array of values to set the property to
|
protected int |
m_PropertyNumber
The current custom property value index when the experiment is running
|
protected PropertyNode[] |
m_PropertyPath
The path to the iterator property
|
protected ResultListener |
m_ResultListener
Where results will be sent
|
protected ResultProducer |
m_ResultProducer
The result producer
|
protected int |
m_RunLower
Lower run number
|
protected int |
m_RunNumber
The current run number when the experiment is running
|
protected int |
m_RunUpper
Upper run number
|
protected boolean |
m_UsePropertyIterator
True if the exp should also iterate over a property of the RP
|
Constructor and Description |
---|
Experiment() |
Modifier and Type | Method and Description |
---|---|
void |
advanceCounters()
Increments iteration counters appropriately.
|
void |
classFirst(boolean flag)
Sets whether the first attribute is treated as the class
for all datasets involved in the experiment.
|
boolean |
getAdvanceDataSetFirst()
Get the value of m_DataSetFirstFirst.
|
int |
getCurrentDatasetNumber()
When an experiment is running, this returns the current dataset number.
|
int |
getCurrentPropertyNumber()
When an experiment is running, this returns the index of the
current custom property value.
|
int |
getCurrentRunNumber()
When an experiment is running, this returns the current run number.
|
DefaultListModel |
getDatasets()
Gets the datasets in the experiment.
|
String |
getNotes()
Get the user notes.
|
String[] |
getOptions()
Gets the current settings of the experiment iterator.
|
Object |
getPropertyArray()
Gets the array of values to set the custom property to.
|
int |
getPropertyArrayLength()
Gets the number of custom iterator values that have been defined
for the experiment.
|
Object |
getPropertyArrayValue(int index)
Gets a specified value from the custom property iterator array.
|
PropertyNode[] |
getPropertyPath()
Gets the path of properties taken to get to the custom property
to iterate over.
|
ResultListener |
getResultListener()
Gets the result listener where results will be sent.
|
ResultProducer |
getResultProducer()
Get the result producer used for the current experiment.
|
String |
getRevision()
Returns the revision string.
|
int |
getRunLower()
Get the lower run number for the experiment.
|
int |
getRunUpper()
Get the upper run number for the experiment.
|
boolean |
getUsePropertyIterator()
Gets whether the custom property iterator should be used.
|
boolean |
hasMoreIterations()
Returns true if there are more iterations to carry out in the experiment.
|
void |
initialize()
Prepares an experiment for running, initializing current iterator
settings.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options..
|
static void |
main(String[] args)
Configures/Runs the Experiment from the command line.
|
void |
nextIteration()
Carries out the next iteration of the experiment.
|
void |
postProcess()
Signals that the experiment is finished running, so that cleanup
can be done.
|
static Experiment |
read(String filename)
Loads an experiment from a file.
|
void |
runExperiment()
Runs all iterations of the experiment, continuing past errors.
|
void |
setAdvanceDataSetFirst(boolean newAdvanceDataSetFirst)
Set the value of m_AdvanceDataSetFirst.
|
void |
setDatasets(DefaultListModel ds)
Set the datasets to use in the experiment
|
void |
setNotes(String newNotes)
Set the user notes.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
protected void |
setProperty(int propertyDepth,
Object origValue)
Recursively sets the custom property value, by setting all values
along the property path.
|
void |
setPropertyArray(Object newPropArray)
Sets the array of values to set the custom property to.
|
void |
setPropertyPath(PropertyNode[] newPropertyPath)
Sets the path of properties taken to get to the custom property
to iterate over.
|
void |
setResultListener(ResultListener newResultListener)
Sets the result listener where results will be sent.
|
void |
setResultProducer(ResultProducer newResultProducer)
Set the result producer used for the current experiment.
|
void |
setRunLower(int newRunLower)
Set the lower run number for the experiment.
|
void |
setRunUpper(int newRunUpper)
Set the upper run number for the experiment.
|
void |
setUsePropertyIterator(boolean newUsePropertyIterator)
Sets whether the custom property iterator should be used.
|
String |
toString()
Gets a string representation of the experiment configuration.
|
static void |
write(String filename,
Experiment exp)
Writes the experiment to disk.
|
public static String FILE_EXTENSION
protected ResultListener m_ResultListener
protected ResultProducer m_ResultProducer
protected int m_RunLower
protected int m_RunUpper
protected DefaultListModel m_Datasets
protected boolean m_UsePropertyIterator
protected PropertyNode[] m_PropertyPath
protected Object m_PropertyArray
protected String m_Notes
protected String[] m_AdditionalMeasures
protected boolean m_ClassFirst
protected boolean m_AdvanceDataSetFirst
protected transient int m_RunNumber
protected transient int m_DatasetNumber
protected transient int m_PropertyNumber
protected transient boolean m_Finished
protected transient Instances m_CurrentInstances
protected transient int m_CurrentProperty
public void classFirst(boolean flag)
flag
- whether the class attribute is the first and not the lastpublic boolean getAdvanceDataSetFirst()
public void setAdvanceDataSetFirst(boolean newAdvanceDataSetFirst)
newAdvanceDataSetFirst
- Value to assign to m_AdvanceRunFirst.public boolean getUsePropertyIterator()
public void setUsePropertyIterator(boolean newUsePropertyIterator)
newUsePropertyIterator
- true if sopublic PropertyNode[] getPropertyPath()
public void setPropertyPath(PropertyNode[] newPropertyPath)
newPropertyPath
- an array of PropertyNodespublic void setPropertyArray(Object newPropArray)
newPropArray
- a value of type Object which should be an
array of the appropriate values.public Object getPropertyArray()
public int getPropertyArrayLength()
public Object getPropertyArrayValue(int index)
index
- the index of the value wantedpublic int getCurrentRunNumber()
public int getCurrentDatasetNumber()
public int getCurrentPropertyNumber()
public void initialize() throws Exception
Exception
- if an error occursprotected void setProperty(int propertyDepth, Object origValue) throws Exception
propertyDepth
- the current position along the property pathorigValue
- the value to set the property toException
- if an error occurspublic boolean hasMoreIterations()
public void nextIteration() throws Exception
Exception
- if an error occurspublic void advanceCounters()
public void runExperiment()
public void postProcess() throws Exception
Exception
- if an error occurspublic DefaultListModel getDatasets()
public void setDatasets(DefaultListModel ds)
ds
- the list of datasets to usepublic ResultListener getResultListener()
public void setResultListener(ResultListener newResultListener)
newResultListener
- the result listener where results will be sent.public ResultProducer getResultProducer()
public void setResultProducer(ResultProducer newResultProducer)
newResultProducer
- result producer to use for the current
experiment.public int getRunUpper()
public void setRunUpper(int newRunUpper)
newRunUpper
- the upper run number for the experiment.public int getRunLower()
public void setRunLower(int newRunLower)
newRunLower
- the lower run number for the experiment.public String getNotes()
public void setNotes(String newNotes)
newNotes
- New user notes.public Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(String[] options) throws Exception
-L <num> The lower run number to start the experiment from. (default 1)
-U <num> The upper run number to end the experiment at (inclusive). (default 10)
-T <arff file> The dataset to run the experiment on. (required, may be specified multiple times)
-P <class name> The full class name of a ResultProducer (required). eg: weka.experiment.RandomSplitResultProducer
-D <class name> The full class name of a ResultListener (required). eg: weka.experiment.CSVResultListener
-N <string> A string containing any notes about the experiment. (default none)
Options specific to result producer weka.experiment.RandomSplitResultProducer:
-P <percent> The percentage of instances to use for training. (default 66)
-D Save raw split evaluator output.
-O <file/directory name/path> The filename where raw output will be stored. If a directory name is specified then then individual outputs will be gzipped, otherwise all output will be zipped to the named file. Use in conjuction with -D. (default splitEvalutorOut.zip)
-W <class name> The full class name of a SplitEvaluator. eg: weka.experiment.ClassifierSplitEvaluator
-R Set when data is not to be randomized and the data sets' size. Is not to be determined via probabilistic rounding.
Options specific to split evaluator weka.experiment.ClassifierSplitEvaluator:
-W <class name> The full class name of the classifier. eg: weka.classifiers.bayes.NaiveBayes
-C <index> The index of the class for which IR statistics are to be output. (default 1)
-I <index> The index of an attribute to output in the results. This attribute should identify an instance in order to know which instances are in the test set of a cross validation. if 0 no output (default 0).
-P Add target and prediction columns to the result for each fold.
Options specific to classifier weka.classifiers.rules.ZeroR:
-D If set, classifier is run in debug mode and may output additional info to the consoleAll options after -- will be passed to the result producer.
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
public String toString()
public static Experiment read(String filename) throws Exception
filename
- the file to load the experiment fromException
- if loading failspublic static void write(String filename, Experiment exp) throws Exception
filename
- the file to write toexp
- the experiment to saveException
- if writing failspublic static void main(String[] args)
args
- command line arguments to the Experiment.public String getRevision()
getRevision
in interface RevisionHandler
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.