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:
adams.core.CleanUpHandler
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,adams.flow.core.FlowContextHandler
,adams.multiprocess.Job
,Serializable
public class WekaCrossValidationJob extends adams.multiprocess.AbstractJob implements adams.flow.core.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 adams.flow.core.Actor
m_FlowContext
the flow context.protected int
m_Fold
the fold.protected adams.core.StatusMessageHandler
m_StatusMessageHandler
for outputting notifications.protected weka.core.Instances
m_Test
the test set.protected weka.core.Instances
m_Train
the training set.
-
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, adams.core.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.adams.flow.core.Actor
getFlowContext()
Returns the flow context, if any.int
getFold()
Returns the fold index.adams.core.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()
protected void
process()
Does the actual execution of the job.void
setFlowContext(adams.flow.core.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.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
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 adams.core.StatusMessageHandler m_StatusMessageHandler
for outputting notifications.
-
m_FlowContext
protected transient adams.flow.core.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, adams.core.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(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Parameters:
value
- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in interfaceadams.flow.core.FlowContextHandler
- 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 adams.core.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()
- Specified by:
preProcessCheck
in classadams.multiprocess.AbstractJob
-
process
protected void process() throws Exception
Does the actual execution of the job.- Specified by:
process
in classadams.multiprocess.AbstractJob
- Throws:
Exception
- if fails to execute job
-
postProcessCheck
protected String postProcessCheck()
Checks whether all post-conditions have been met.- Specified by:
postProcessCheck
in classadams.multiprocess.AbstractJob
- 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 interfaceadams.core.CleanUpHandler
- Specified by:
cleanUp
in interfaceadams.multiprocess.Job
- Overrides:
cleanUp
in classadams.multiprocess.AbstractJob
-
toString
public String toString()
Returns a string representation of this job.- Specified by:
toString
in classadams.multiprocess.AbstractJob
- Returns:
- the job as string
-
-