Package weka.experiment
Class DatabaseResultProducer
java.lang.Object
weka.experiment.DatabaseUtils
weka.experiment.DatabaseResultListener
weka.experiment.DatabaseResultProducer
- All Implemented Interfaces:
Serializable,AdditionalMeasureProducer,OptionHandler,RevisionHandler,ResultListener,ResultProducer
public class DatabaseResultProducer
extends DatabaseResultListener
implements ResultProducer, OptionHandler, AdditionalMeasureProducer
Examines a database and extracts out the results
produced by the specified ResultProducer and submits them to the specified
ResultListener. If a result needs to be generated, the ResultProducer is used
to obtain the result.
Valid options are:
-F <field name> The name of the database field to cache over. eg: "Fold" (default none)
-W <class name> The full class name of a ResultProducer. eg: weka.experiment.CrossValidationResultProducer
Options specific to result producer weka.experiment.CrossValidationResultProducer:
-X <number of folds> The number of folds to use for the cross-validation. (default 10)
-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
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 console
- Version:
- $Revision: 11247 $
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from class weka.experiment.DatabaseUtils
BOOL, BYTE, DATE, DOUBLE, EXP_INDEX_TABLE, EXP_RESULT_COL, EXP_RESULT_PREFIX, EXP_SETUP_COL, EXP_TYPE_COL, FLOAT, INTEGER, LONG, PROPERTY_FILE, SHORT, STRING, TEXT, TIME, TIMESTAMP -
Constructor Summary
ConstructorsConstructorDescriptionCreates the DatabaseResultProducer, letting the parent constructor do it's thing. -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptResult(ResultProducer rp, Object[] key, Object[] result) Accepts results from a ResultProducer.voiddoRun(int run) Gets the results for a specified run number.voiddoRunKeys(int run) Gets the keys for a specified run number.Returns an enumeration of any additional measure names that might be in the result producerGets a description of the internal settings of the result producer, sufficient for distinguishing a ResultProducer instance from another with different settings (ignoring those settings set through this interface).String[]Gets the names of each of the columns produced for a single run.Object[]Gets the data types of each of the columns produced for a single run.doublegetMeasure(String additionalMeasureName) Returns the value of the named measureString[]Gets the current settings of the result producer.String[]Gets the names of each of the columns produced for a single run.Get the ResultProducer.Object[]Gets the data types of each of the columns produced for a single run.Returns the revision string.Returns a string describing this result producerbooleanisResultRequired(ResultProducer rp, Object[] key) Determines whether the results for a specified key must be generated.Returns an enumeration describing the available options..voidWhen this method is called, it indicates that no more requests to generate results for the current experiment will be sent.voidWhen this method is called, it indicates that no more results will be sent that need to be grouped together in any way.voidPrepare to generate results.voidPrepare for the results to be received.Returns the tip text for this propertyvoidsetAdditionalMeasures(String[] additionalMeasures) Set a list of method names for additional measures to look for in SplitEvaluators.voidsetInstances(Instances instances) Sets the dataset that results will be obtained for.voidsetOptions(String[] options) Parses a given list of options.voidsetResultListener(ResultListener listener) Sets the object to send results of each run to.voidsetResultProducer(ResultProducer newResultProducer) Set the ResultProducer.toString()Gets a text descrption of the result producer.Methods inherited from class weka.experiment.DatabaseResultListener
cacheKeyNameTipText, determineColumnConstraints, getCacheKeyName, setCacheKeyNameMethods inherited from class weka.experiment.DatabaseUtils
arrayToString, attributeCaseFix, close, close, connectToDatabase, createExperimentIndex, createExperimentIndexEntry, createResultsTable, databaseURLTipText, debugTipText, disconnectFromDatabase, execute, experimentIndexExists, getDatabaseURL, getDebug, getKeywords, getKeywordsMaskChar, getPassword, getResultFromTable, getResultSet, getResultsTableName, getSupportedCursorScrollType, getUsername, initialize, initialize, isConnected, isCursorScrollable, isCursorScrollSensitive, isKeyword, maskKeyword, passwordTipText, processKeyString, putResultInTable, select, setDatabaseURL, setDebug, setKeywords, setKeywordsMaskChar, setPassword, setUsername, tableExists, translateDBColumnType, typeName, update, usernameTipText
-
Constructor Details
-
DatabaseResultProducer
Creates the DatabaseResultProducer, letting the parent constructor do it's thing.- Throws:
Exception- if an error occurs
-
-
Method Details
-
globalInfo
Returns a string describing this result producer- Overrides:
globalInfoin classDatabaseResultListener- Returns:
- a description of the result producer suitable for displaying in the explorer/experimenter gui
-
doRunKeys
Gets the keys for a specified run number. Different run numbers correspond to different randomizations of the data. Keys produced should be sent to the current ResultListener- Specified by:
doRunKeysin interfaceResultProducer- Parameters:
run- the run number to get keys for.- Throws:
Exception- if a problem occurs while getting the keys
-
doRun
Gets the results for a specified run number. Different run numbers correspond to different randomizations of the data. Results produced should be sent to the current ResultListener- Specified by:
doRunin interfaceResultProducer- Parameters:
run- the run number to get results for.- Throws:
Exception- if a problem occurs while getting the results
-
preProcess
Prepare for the results to be received.- Specified by:
preProcessin interfaceResultListener- Overrides:
preProcessin classDatabaseResultListener- Parameters:
rp- the ResultProducer that will generate the results- Throws:
Exception- if an error occurs during preprocessing.
-
postProcess
When this method is called, it indicates that no more results will be sent that need to be grouped together in any way.- Specified by:
postProcessin interfaceResultListener- Overrides:
postProcessin classDatabaseResultListener- Parameters:
rp- the ResultProducer that generated the results- Throws:
Exception- if an error occurs
-
preProcess
Prepare to generate results. The ResultProducer should call preProcess(this) on the ResultListener it is to send results to.- Specified by:
preProcessin interfaceResultProducer- Throws:
Exception- if an error occurs during preprocessing.
-
postProcess
When this method is called, it indicates that no more requests to generate results for the current experiment will be sent. The ResultProducer should call preProcess(this) on the ResultListener it is to send results to.- Specified by:
postProcessin interfaceResultProducer- Throws:
Exception- if an error occurs
-
acceptResult
Accepts results from a ResultProducer.- Specified by:
acceptResultin interfaceResultListener- Overrides:
acceptResultin classDatabaseResultListener- Parameters:
rp- the ResultProducer that generated the resultskey- an array of Objects (Strings or Doubles) that uniquely identify a result for a given ResultProducer with given compatibilityStateresult- the results stored in an array. The objects stored in the array may be Strings, Doubles, or null (for the missing value).- Throws:
Exception- if the result could not be accepted.
-
isResultRequired
Determines whether the results for a specified key must be generated.- Specified by:
isResultRequiredin interfaceResultListener- Overrides:
isResultRequiredin classDatabaseResultListener- Parameters:
rp- the ResultProducer wanting to generate the resultskey- an array of Objects (Strings or Doubles) that uniquely identify a result for a given ResultProducer with given compatibilityState- Returns:
- true if the result should be generated
- Throws:
Exception- if it could not be determined if the result is needed.
-
getKeyNames
Gets the names of each of the columns produced for a single run.- Specified by:
getKeyNamesin interfaceResultProducer- Returns:
- an array containing the name of each column
- Throws:
Exception- if something goes wrong.
-
getKeyTypes
Gets the data types of each of the columns produced for a single run. This method should really be static.- Specified by:
getKeyTypesin interfaceResultProducer- Returns:
- an array containing objects of the type of each column. The objects should be Strings, or Doubles.
- Throws:
Exception- if something goes wrong.
-
getResultNames
Gets the names of each of the columns produced for a single run. A new result field is added for the number of results used to produce each average. If only averages are being produced the names are not altered, if standard deviations are produced then "Dev_" and "Avg_" are prepended to each result deviation and average field respectively.- Specified by:
getResultNamesin interfaceResultProducer- Returns:
- an array containing the name of each column
- Throws:
Exception- if something goes wrong.
-
getResultTypes
Gets the data types of each of the columns produced for a single run.- Specified by:
getResultTypesin interfaceResultProducer- Returns:
- an array containing objects of the type of each column. The objects should be Strings, or Doubles.
- Throws:
Exception- if something goes wrong.
-
getCompatibilityState
Gets a description of the internal settings of the result producer, sufficient for distinguishing a ResultProducer instance from another with different settings (ignoring those settings set through this interface). For example, a cross-validation ResultProducer may have a setting for the number of folds. For a given state, the results produced should be compatible. Typically if a ResultProducer is an OptionHandler, this string will represent the command line arguments required to set the ResultProducer to that state.- Specified by:
getCompatibilityStatein interfaceResultProducer- Returns:
- the description of the ResultProducer state, or null if no state is defined
-
listOptions
Returns an enumeration describing the available options..- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-F <field name> The name of the database field to cache over. eg: "Fold" (default none)
-W <class name> The full class name of a ResultProducer. eg: weka.experiment.CrossValidationResultProducer
Options specific to result producer weka.experiment.CrossValidationResultProducer:
-X <number of folds> The number of folds to use for the cross-validation. (default 10)
-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
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 console
All option after -- will be passed to the result producer.- Specified by:
setOptionsin interfaceOptionHandler- 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 result producer.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- an array of strings suitable for passing to setOptions
-
setAdditionalMeasures
Set a list of method names for additional measures to look for in SplitEvaluators. This could contain many measures (of which only a subset may be produceable by the current resultProducer) if an experiment is the type that iterates over a set of properties.- Specified by:
setAdditionalMeasuresin interfaceResultProducer- Parameters:
additionalMeasures- an array of measure names, null if none
-
enumerateMeasures
Returns an enumeration of any additional measure names that might be in the result producer- 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
-
setInstances
Sets the dataset that results will be obtained for.- Specified by:
setInstancesin interfaceResultProducer- Parameters:
instances- a value of type 'Instances'.
-
setResultListener
Sets the object to send results of each run to.- Specified by:
setResultListenerin interfaceResultProducer- Parameters:
listener- a value of type 'ResultListener'
-
resultProducerTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getResultProducer
Get the ResultProducer.- Returns:
- the ResultProducer.
-
setResultProducer
Set the ResultProducer.- Parameters:
newResultProducer- new ResultProducer to use.
-
toString
Gets a text descrption of the result producer. -
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classDatabaseResultListener- Returns:
- the revision
-