Package adams.flow.transformer
Class WekaClassifierRanker.RankingJob
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.multiprocess.AbstractJob
-
- adams.flow.transformer.WekaClassifierRanker.RankingJob
-
- All Implemented Interfaces:
adams.core.CleanUpHandler
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,adams.multiprocess.Job
,Serializable
- Enclosing class:
- WekaClassifierRanker
public static class WekaClassifierRanker.RankingJob extends adams.multiprocess.AbstractJob
A job class specific to ranking classifiers.- 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_BestClassifier
the best classifier.protected weka.classifiers.Classifier
m_Classifier
the classifier to evaluate.protected WekaLabelIndex
m_ClassLabel
the class label index.protected StoppableEvaluation
m_Evaluation
the current evaluation.protected String
m_EvaluationError
for storing evaluating errors.protected int
m_Folds
the number of folds to use.protected int
m_Index
the index in actor's input array.protected WekaClassifierRanker.Measure
m_Measure
the measure to use for ranking.protected boolean
m_OutputBestSetup
whether to output the best classifier.protected weka.classifiers.meta.multisearch.Performance
m_Performance
the performance.protected long
m_Seed
the seed value to use.protected weka.core.Instances
m_Test
the test data to evaluate with (if folds less than 2).protected weka.core.Instances
m_Train
the train data to evaluate with.
-
Constructor Summary
Constructors Constructor Description RankingJob(weka.classifiers.Classifier cls, int index, weka.core.Instances train, weka.core.Instances test, long seed, int folds, WekaClassifierRanker.Measure measure, WekaLabelIndex classLabel, boolean best)
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.protected String
getAdditionalErrorInformation()
Returns additional information to be added to the error message.weka.classifiers.Classifier
getBestClassifier()
Returns the best classifier found.protected weka.classifiers.Classifier
getBestClassifier(weka.classifiers.Classifier template, weka.classifiers.Classifier trained)
In case of GridSearch/MultiSearch the best setup is returned, otherwise the classifier itself.weka.classifiers.Classifier
getClassifier()
Returns the classifier being used.int
getFolds()
Returns the number of folds.int
getIndex()
Returns the index of the classifier in the actor's input array.WekaClassifierRanker.Measure
getMeasure()
Returns the measure for ranking.boolean
getOutputBestSetup()
Returns whether the best setup is output in case of optimizers like GridSearch/MultiSearch.weka.classifiers.meta.multisearch.Performance
getPerformance()
The generated performance.long
getSeed()
Returns the seed value.weka.core.Instances
getTest()
The test data.weka.core.Instances
getTrain()
The training data.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
stopExecution()
Stops the execution.String
toString()
Returns a string representation of the job.-
Methods inherited from class adams.multiprocess.AbstractJob
execute, getExecutionError, getJobCompleteListener, getJobInfo, getProgressInfo, hasExecutionError, isComplete, isStopped, jobCompleted, setJobCompleteListener, setJobInfo, setProgressInfo
-
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_Index
protected int m_Index
the index in actor's input array.
-
m_Train
protected weka.core.Instances m_Train
the train data to evaluate with.
-
m_Test
protected weka.core.Instances m_Test
the test data to evaluate with (if folds less than 2).
-
m_Seed
protected long m_Seed
the seed value to use.
-
m_Folds
protected int m_Folds
the number of folds to use.
-
m_Measure
protected WekaClassifierRanker.Measure m_Measure
the measure to use for ranking.
-
m_ClassLabel
protected WekaLabelIndex m_ClassLabel
the class label index.
-
m_Performance
protected weka.classifiers.meta.multisearch.Performance m_Performance
the performance.
-
m_EvaluationError
protected String m_EvaluationError
for storing evaluating errors.
-
m_OutputBestSetup
protected boolean m_OutputBestSetup
whether to output the best classifier.
-
m_BestClassifier
protected weka.classifiers.Classifier m_BestClassifier
the best classifier.
-
m_Evaluation
protected transient StoppableEvaluation m_Evaluation
the current evaluation.
-
-
Constructor Detail
-
RankingJob
public RankingJob(weka.classifiers.Classifier cls, int index, weka.core.Instances train, weka.core.Instances test, long seed, int folds, WekaClassifierRanker.Measure measure, WekaLabelIndex classLabel, boolean best)
Initializes the job.- Parameters:
cls
- the classifier to evaluateindex
- the index of the classifier in input arraytrain
- the training data to usetest
- the test data to useseed
- the seed value to usefolds
- the number of folds to usemeasure
- the measure to use for rankingclassLabel
- the class label index to usebest
- whether to output the best classifier setup (for optimizers)
-
-
Method Detail
-
getClassifier
public weka.classifiers.Classifier getClassifier()
Returns the classifier being used.- Returns:
- the classifier in use
-
getIndex
public int getIndex()
Returns the index of the classifier in the actor's input array.- Returns:
- the index
-
getTrain
public weka.core.Instances getTrain()
The training data.- Returns:
- the training data
-
getTest
public weka.core.Instances getTest()
The test data.- Returns:
- the test data
-
getSeed
public long getSeed()
Returns the seed value.- Returns:
- the seed value
-
getFolds
public int getFolds()
Returns the number of folds.- Returns:
- the folds
-
getMeasure
public WekaClassifierRanker.Measure getMeasure()
Returns the measure for ranking.- Returns:
- the measure
-
getPerformance
public weka.classifiers.meta.multisearch.Performance getPerformance()
The generated performance.- Returns:
- the performance, can be null
-
getBestClassifier
public weka.classifiers.Classifier getBestClassifier()
Returns the best classifier found. For optimizers like GridSearch, this outputs the best setup found. For all others, that's the same setup as the actual classifier that was evaluated.- Returns:
- the best setup or the original setup
-
getOutputBestSetup
public boolean getOutputBestSetup()
Returns whether the best setup is output in case of optimizers like GridSearch/MultiSearch.- Returns:
- true if the best setup is output
-
preProcessCheck
protected String preProcessCheck()
Checks whether all pre-conditions have been met.- Specified by:
preProcessCheck
in classadams.multiprocess.AbstractJob
- Returns:
- null if everything is OK, otherwise an error message
-
getBestClassifier
protected weka.classifiers.Classifier getBestClassifier(weka.classifiers.Classifier template, weka.classifiers.Classifier trained)
In case of GridSearch/MultiSearch the best setup is returned, otherwise the classifier itself.- Parameters:
template
- the template classifiertrained
- the trained classifier- Returns:
- either the best classifier (in case of GridSearch/MultiSearch) or the template
-
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
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classadams.multiprocess.AbstractJob
-
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. Sets the input data to null.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
- Specified by:
cleanUp
in interfaceadams.multiprocess.Job
- Overrides:
cleanUp
in classadams.multiprocess.AbstractJob
-
getAdditionalErrorInformation
protected String getAdditionalErrorInformation()
Returns additional information to be added to the error message.- Overrides:
getAdditionalErrorInformation
in classadams.multiprocess.AbstractJob
- Returns:
- the additional information
-
toString
public String toString()
Returns a string representation of the job.- Specified by:
toString
in classadams.multiprocess.AbstractJob
- Returns:
- a string representation
-
-