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.Classifier
m_Classifier
the classifier to evaluate.protected boolean
m_DiscardPredictions
whether to discard the predictions.protected weka.classifiers.Evaluation
m_Evaluation
the evaluation.protected Actor
m_FlowContext
the flow context.protected int
m_Fold
the fold.protected StatusMessageHandler
m_StatusMessageHandler
for outputting notifications.protected weka.core.Instances
m_Test
the test set.protected weka.core.Instances
m_Train
the 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 void
cleanUp()
Cleans up data structures, frees up memory.weka.classifiers.Classifier
getClassifier()
Returns the classifier (should be built after the job finished).boolean
getDiscardPredictions()
Returns whether the predictions are discarded.weka.classifiers.Evaluation
getEvaluation()
Returns the generated evaluation object.Actor
getFlowContext()
Returns the flow context, if any.int
getFold()
Returns the fold index.StatusMessageHandler
getStatusMessageHandler()
Returns the status message handler.weka.core.Instances
getTest()
Returns the test set.weka.core.Instances
getTrain()
Returns the training set.protected String
postProcessCheck()
Checks whether all post-conditions have been met.protected String
preProcessCheck()
Checks whether all pre-conditions have been met.protected void
process()
Does the actual execution of the job.void
setFlowContext(Actor value)
Sets the flow context.String
toString()
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, stopExecution
-
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 weka.classifiers.Evaluation 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:
setFlowContext
in interfaceFlowContextHandler
- Parameters:
value
- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in 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:AbstractJob
Checks whether all pre-conditions have been met.- Specified by:
preProcessCheck
in classAbstractJob
- Returns:
- null if everything is OK, otherwise an error message
-
process
protected void process() throws Exception
Does the actual execution of the job.- Specified by:
process
in classAbstractJob
- Throws:
Exception
- if fails to execute job
-
postProcessCheck
protected String postProcessCheck()
Checks whether all post-conditions have been met.- Specified by:
postProcessCheck
in classAbstractJob
- Returns:
- null if everything is OK, otherwise an error message
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Removes dependencies and job parameters.- Specified by:
cleanUp
in interfaceCleanUpHandler
- Specified by:
cleanUp
in interfaceJob
- Overrides:
cleanUp
in classAbstractJob
-
toString
public String toString()
Returns a string representation of this job.- Specified by:
toString
in classAbstractJob
- Returns:
- the job as string
-
-