Package adams.multiprocess
Class WekaCrossValidationJob
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.multiprocess.AbstractJob
-
- adams.multiprocess.WekaCrossValidationJob
-
- All Implemented Interfaces:
CleanUpHandler,LoggingLevelHandler,LoggingSupporter,SizeOfHandler,Stoppable,StoppableWithFeedback,FlowContextHandler,Job,Serializable
public class WekaCrossValidationJob extends AbstractJob implements FlowContextHandler
For evaluation of a single train/test fold in parallel.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.classifiers.Classifierm_Classifierthe classifier to evaluate.protected booleanm_DiscardPredictionswhether to discard the predictions.protected StoppableEvaluationm_Evaluationthe evaluation.protected Actorm_FlowContextthe flow context.protected intm_Foldthe fold.protected StatusMessageHandlerm_StatusMessageHandlerfor outputting notifications.protected weka.core.Instancesm_Testthe test set.protected weka.core.Instancesm_Trainthe training set.-
Fields inherited from class adams.multiprocess.AbstractJob
m_Complete, m_ExecutionError, m_JobCompleteListener, m_JobInfo, m_ProgressInfo, m_Stopped
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description WekaCrossValidationJob(weka.classifiers.Classifier classifier, weka.core.Instances train, weka.core.Instances test, int fold, boolean discardPred)Initializes the job.WekaCrossValidationJob(weka.classifiers.Classifier classifier, weka.core.Instances train, weka.core.Instances test, int fold, boolean discardPred, StatusMessageHandler handler)Initializes the job.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.weka.classifiers.ClassifiergetClassifier()Returns the classifier (should be built after the job finished).booleangetDiscardPredictions()Returns whether the predictions are discarded.weka.classifiers.EvaluationgetEvaluation()Returns the generated evaluation object.ActorgetFlowContext()Returns the flow context, if any.intgetFold()Returns the fold index.StatusMessageHandlergetStatusMessageHandler()Returns the status message handler.weka.core.InstancesgetTest()Returns the test set.weka.core.InstancesgetTrain()Returns the training set.protected StringpostProcessCheck()Checks whether all post-conditions have been met.protected StringpreProcessCheck()Checks whether all pre-conditions have been met.protected voidprocess()Does the actual execution of the job.voidsetFlowContext(Actor value)Sets the flow context.voidstopExecution()Stops the execution.StringtoString()Returns a string representation of this job.-
Methods inherited from class adams.multiprocess.AbstractJob
execute, getAdditionalErrorInformation, getExecutionError, getJobCompleteListener, getJobInfo, getProgressInfo, hasExecutionError, isComplete, isStopped, jobCompleted, setJobCompleteListener, setJobInfo, setProgressInfo
-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
-
-
-
Field Detail
-
m_Classifier
protected weka.classifiers.Classifier m_Classifier
the classifier to evaluate.
-
m_Fold
protected int m_Fold
the fold.
-
m_Train
protected weka.core.Instances m_Train
the training set.
-
m_Test
protected weka.core.Instances m_Test
the test set.
-
m_DiscardPredictions
protected boolean m_DiscardPredictions
whether to discard the predictions.
-
m_Evaluation
protected StoppableEvaluation m_Evaluation
the evaluation.
-
m_StatusMessageHandler
protected transient StatusMessageHandler m_StatusMessageHandler
for outputting notifications.
-
m_FlowContext
protected transient Actor m_FlowContext
the flow context.
-
-
Constructor Detail
-
WekaCrossValidationJob
public WekaCrossValidationJob(weka.classifiers.Classifier classifier, weka.core.Instances train, weka.core.Instances test, int fold, boolean discardPred)Initializes the job.- Parameters:
classifier- the classifier to evaluatetrain- the training settest- the test setfold- the fold indexdiscardPred- whether to discard the predictions
-
WekaCrossValidationJob
public WekaCrossValidationJob(weka.classifiers.Classifier classifier, weka.core.Instances train, weka.core.Instances test, int fold, boolean discardPred, StatusMessageHandler handler)Initializes the job.- Parameters:
classifier- the classifier to evaluatetrain- the training settest- the test setfold- the fold indexdiscardPred- whether to discard the predictionshandler- for displaying notifications, can be null
-
-
Method Detail
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceFlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceFlowContextHandler- Returns:
- the actor, null if none available
-
getTrain
public weka.core.Instances getTrain()
Returns the training set.- Returns:
- the dataset
-
getTest
public weka.core.Instances getTest()
Returns the test set.- Returns:
- the dataset
-
getFold
public int getFold()
Returns the fold index.- Returns:
- the fold
-
getDiscardPredictions
public boolean getDiscardPredictions()
Returns whether the predictions are discarded.- Returns:
- true if discarded
-
getStatusMessageHandler
public StatusMessageHandler getStatusMessageHandler()
Returns the status message handler.- Returns:
- the handler
-
getEvaluation
public weka.classifiers.Evaluation getEvaluation()
Returns the generated evaluation object.- Returns:
- the evaluation, null if not available
-
getClassifier
public weka.classifiers.Classifier getClassifier()
Returns the classifier (should be built after the job finished).- Returns:
- the classifier
-
preProcessCheck
protected String preProcessCheck()
Description copied from class:AbstractJobChecks whether all pre-conditions have been met.- Specified by:
preProcessCheckin classAbstractJob- Returns:
- null if everything is OK, otherwise an error message
-
process
protected void process() throws ExceptionDoes the actual execution of the job.- Specified by:
processin classAbstractJob- Throws:
Exception- if fails to execute job
-
postProcessCheck
protected String postProcessCheck()
Checks whether all post-conditions have been met.- Specified by:
postProcessCheckin classAbstractJob- Returns:
- null if everything is OK, otherwise an error message
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractJob
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Removes dependencies and job parameters.- Specified by:
cleanUpin interfaceCleanUpHandler- Specified by:
cleanUpin interfaceJob- Overrides:
cleanUpin classAbstractJob
-
toString
public String toString()
Returns a string representation of this job.- Specified by:
toStringin classAbstractJob- Returns:
- the job as string
-
-