Class 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
    • Field Detail

      • 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_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_JobRunnerSetup

        protected transient JobRunnerSetup m_JobRunnerSetup
        the jobrunner setup.
      • m_JobRunner

        protected JobRunner m_JobRunner
        the job runner for evaluating the setups.
    • Constructor Detail

      • WekaClassifierRanker

        public WekaClassifierRanker()
    • Method Detail

      • 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:
        setSeed in interface Randomizable
        Parameters:
        value - the seed
      • getSeed

        public long getSeed()
        Returns the seed value.
        Specified by:
        getSeed in interface Randomizable
        Returns:
        the seed
      • seedTipText

        public String seedTipText()
        Returns the tip text for this property.
        Specified by:
        seedTipText in interface Randomizable
        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:
        setNumThreads in interface ThreadLimiter
        Parameters:
        value - the number of threads
      • getNumThreads

        public int getNumThreads()
        Returns the number of threads in use.
        Specified by:
        getNumThreads in interface ThreadLimiter
        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.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        weka.classifiers.Classifier[].class
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        weka.classifiers.Classifier[].class
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message
      • pauseExecution

        public void pauseExecution()
        Pauses the execution.
        Specified by:
        pauseExecution in interface Pausable
      • isPaused

        public boolean isPaused()
        Returns whether the object is currently paused.
        Specified by:
        isPaused in interface Pausable
        Returns:
        true if object is paused
      • resumeExecution

        public void resumeExecution()
        Resumes the execution.
        Specified by:
        resumeExecution in interface Pausable