Package adams.flow.transformer
Class WekaClassifierRanker
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.transformer.AbstractTransformer
-
- adams.flow.transformer.WekaClassifierRanker
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,Pausable,QuickInfoSupporter,Randomizable,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,ThreadLimiter,VariablesInspectionHandler,FlowPauseStateListener,VariableChangeListener,Actor,ErrorHandler,InputConsumer,OutputProducer,Serializable,Comparable
public class WekaClassifierRanker extends AbstractTransformer implements Randomizable, Pausable, FlowPauseStateListener, ThreadLimiter
Performs a quick evaluation using cross-validation on a single dataset (or evaluation on a separate test set if the number of folds is less than 2) to rank the classifiers received on the input and forwarding the x best ones. Further evaluation can be performed using the Experimenter.
Input/output:
- accepts:
weka.classifiers.Classifier[]
- generates:
weka.classifiers.Classifier[]
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: WekaClassifierRanker
-annotation <adams.core.base.BaseText> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors. default: false
-max <int> (property: max) The maximum number of top-ranked classifiers to forward; use -1 to forward all of them (ranked array). default: 3 minimum: -1
-seed <long> (property: seed) The seed value to use in the cross-validation. default: 1
-folds <int> (property: folds) The number of folds to use in cross-validation. default: 10 minimum: 1
-measure <CC|RMSE|RRSE|MAE|RAE|COMBINED|ACC|KAPPA> (property: measure) The measure used for ranking the classifiers. default: CC
-train <adams.flow.core.CallableActorReference> (property: train) The name of the callable actor that is used for obtaining the training set. default: train
-test <adams.flow.core.CallableActorReference> (property: test) The name of the callable actor that is used for obtaining the test set ( only if folds <2). default: test
-output-best <boolean> (property: outputBestSetup) If true, then for optimizers like GridSearch and MultiSearch the best setup that was found will be output instead of the optimizer setup. default: false
-num-threads <int> (property: numThreads) The number of threads to use for evaluating the classifiers in parallel (-1 means one for each core/cpu). default: -1 minimum: -1
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWekaClassifierRanker.MeasureThe performance measure to use.static classWekaClassifierRanker.RankingJobA job class specific to ranking classifiers.
-
Field Summary
Fields Modifier and Type Field Description protected WekaLabelIndexm_ClassLabelthe class label (in case of class-specific measures).protected intm_Foldsthe number of folds to use in cross-validation.protected CallableActorHelperm_Helperthe helper class.protected JobRunnerm_JobRunnerthe job runner for evaluating the setups.protected JobRunnerSetupm_JobRunnerSetupthe jobrunner setup.protected intm_Maxthe maximum number of top-ranked classifiers to forward.protected WekaClassifierRanker.Measurem_Measurethe measure for the evaluation.protected intm_NumThreadsthe number of threads to use for parallel execution.protected booleanm_OutputBestSetupwhether to output the best setup in case of GridSearch/MultiSearch.protected longm_Seedthe random seed to use.protected CallableActorReferencem_Testthe callable actor to obtain the test dataset for train/test evaluation from.protected CallableActorReferencem_Trainthe callable actor to obtain the training dataset from.-
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description WekaClassifierRanker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.StringclassLabelTipText()Returns the tip text for this property.voidcleanUp()Frees up memory in a "destructive" non-reversible way.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.voidflowPauseStateChanged(FlowPauseStateEvent e)Gets called when the pause state of the flow changes.StringfoldsTipText()Returns the tip text for this property.Class[]generates()Returns the class of objects that it generates.WekaLabelIndexgetClassLabel()Returns the class label index to use for class-specific measures.intgetFolds()Returns the number of folds to use.intgetMax()Returns the maximum number of top-ranked classifiers to forward.WekaClassifierRanker.MeasuregetMeasure()Returns the measure used for ranking the classifiers.intgetNumThreads()Returns the number of threads in use.booleangetOutputBestSetup()Returns whether to output the best setup for optimizers like GridSearch and MultiSearch.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.longgetSeed()Returns the seed value.CallableActorReferencegetTest()Returns the name of the callable actor to obtain the test set.CallableActorReferencegetTrain()Returns the name of the callable actor to obtain the training set.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.booleanisPaused()Returns whether the object is currently paused.StringmaxTipText()Returns the tip text for this property.StringmeasureTipText()Returns the tip text for this property.StringnumThreadsTipText()Returns the tip text for this property.StringoutputBestSetupTipText()Returns the tip text for this property.voidpauseExecution()Pauses the execution.voidresumeExecution()Resumes the execution.StringseedTipText()Returns the tip text for this property.voidsetClassLabel(WekaLabelIndex value)Sets the class label index to use for class-specific measures.voidsetFolds(int value)Sets the number of folds to use.voidsetMax(int value)Sets the maximum number of top-ranked classifiers to forward.voidsetMeasure(WekaClassifierRanker.Measure value)Sets the measure to use for ranking the classifiers.voidsetNumThreads(int value)Sets the number of threads to use.voidsetOutputBestSetup(boolean value)Sets whether to output the best setup found for optimizers like GridSearch and MultiSearch.voidsetSeed(long value)Sets the seed value.voidsetTest(CallableActorReference value)Sets the name of the callable actor to obtain the test set.voidsetTrain(CallableActorReference value)Sets the name of the callable actor to obtain the training set.StringsetUp()Initializes the item for flow execution.voidstopExecution()Stops the execution.StringtestTipText()Returns the tip text for this property.StringtrainTipText()Returns the tip text for this property.-
Methods inherited from class adams.flow.transformer.AbstractTransformer
backupState, currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, restoreState, wrapUp
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
m_Train
protected CallableActorReference m_Train
the callable actor to obtain the training dataset from.
-
m_Test
protected CallableActorReference m_Test
the callable actor to obtain the test dataset for train/test evaluation from.
-
m_Max
protected int m_Max
the maximum number of top-ranked classifiers to forward.
-
m_Seed
protected long m_Seed
the random seed to use.
-
m_Folds
protected int m_Folds
the number of folds to use in cross-validation.
-
m_Measure
protected WekaClassifierRanker.Measure m_Measure
the measure for the evaluation.
-
m_ClassLabel
protected WekaLabelIndex m_ClassLabel
the class label (in case of class-specific measures).
-
m_OutputBestSetup
protected boolean m_OutputBestSetup
whether to output the best setup in case of GridSearch/MultiSearch.
-
m_NumThreads
protected int m_NumThreads
the number of threads to use for parallel execution.
-
m_Helper
protected CallableActorHelper m_Helper
the helper class.
-
m_JobRunnerSetup
protected transient JobRunnerSetup m_JobRunnerSetup
the jobrunner setup.
-
m_JobRunner
protected JobRunner m_JobRunner
the job runner for evaluating the setups.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractActor
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- Returns:
- null if no info available, otherwise short string
-
setMax
public void setMax(int value)
Sets the maximum number of top-ranked classifiers to forward.- Parameters:
value- the maximum number, use -1 for all
-
getMax
public int getMax()
Returns the maximum number of top-ranked classifiers to forward.- Returns:
- the maximum number, -1 if all returned
-
maxTipText
public String maxTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSeed
public void setSeed(long value)
Sets the seed value.- Specified by:
setSeedin interfaceRandomizable- Parameters:
value- the seed
-
getSeed
public long getSeed()
Returns the seed value.- Specified by:
getSeedin interfaceRandomizable- Returns:
- the seed
-
seedTipText
public String seedTipText()
Returns the tip text for this property.- Specified by:
seedTipTextin interfaceRandomizable- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFolds
public void setFolds(int value)
Sets the number of folds to use.- Parameters:
value- the folds
-
getFolds
public int getFolds()
Returns the number of folds to use.- Returns:
- the folds
-
foldsTipText
public String foldsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMeasure
public void setMeasure(WekaClassifierRanker.Measure value)
Sets the measure to use for ranking the classifiers.- Parameters:
value- the ranking measure
-
getMeasure
public WekaClassifierRanker.Measure getMeasure()
Returns the measure used for ranking the classifiers.- Returns:
- the ranking measure
-
measureTipText
public String measureTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setClassLabel
public void setClassLabel(WekaLabelIndex value)
Sets the class label index to use for class-specific measures.- Parameters:
value- the label index
-
getClassLabel
public WekaLabelIndex getClassLabel()
Returns the class label index to use for class-specific measures.- Returns:
- the label index
-
classLabelTipText
public String classLabelTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTrain
public void setTrain(CallableActorReference value)
Sets the name of the callable actor to obtain the training set.- Parameters:
value- the name of the callable actor
-
getTrain
public CallableActorReference getTrain()
Returns the name of the callable actor to obtain the training set.- Returns:
- the name of the callable actor
-
trainTipText
public String trainTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTest
public void setTest(CallableActorReference value)
Sets the name of the callable actor to obtain the test set.- Parameters:
value- the name of the callable actor
-
getTest
public CallableActorReference getTest()
Returns the name of the callable actor to obtain the test set.- Returns:
- the name of the callable actor
-
testTipText
public String testTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOutputBestSetup
public void setOutputBestSetup(boolean value)
Sets whether to output the best setup found for optimizers like GridSearch and MultiSearch.- Parameters:
value- true if the best setup is to be output
-
getOutputBestSetup
public boolean getOutputBestSetup()
Returns whether to output the best setup for optimizers like GridSearch and MultiSearch.- Returns:
- true if the best setup is output
-
outputBestSetupTipText
public String outputBestSetupTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumThreads
public void setNumThreads(int value)
Sets the number of threads to use.- Specified by:
setNumThreadsin interfaceThreadLimiter- Parameters:
value- the number of threads
-
getNumThreads
public int getNumThreads()
Returns the number of threads in use.- Specified by:
getNumThreadsin interfaceThreadLimiter- Returns:
- the number of threads
-
numThreadsTipText
public String numThreadsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceInputConsumer- Returns:
- weka.classifiers.Classifier[].class
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generatesin interfaceOutputProducer- Returns:
- weka.classifiers.Classifier[].class
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
flowPauseStateChanged
public void flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.- Specified by:
flowPauseStateChangedin interfaceFlowPauseStateListener- Parameters:
e- the event
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractActor
-
cleanUp
public void cleanUp()
Frees up memory in a "destructive" non-reversible way.- Specified by:
cleanUpin interfaceActor- Specified by:
cleanUpin interfaceCleanUpHandler- Overrides:
cleanUpin classAbstractActor
-
-