Class WekaTrainClassifier

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, JobRunnerSupporter, Serializable, Comparable

    public class WekaTrainClassifier
    extends AbstractTransformer
    implements JobRunnerSupporter
    Trains a classifier based on the incoming dataset and outputs the built classifier alongside the training header (in a model container).
    Incremental training is performed, if the input are weka.core.Instance objects and the classifier implements weka.classifiers.UpdateableClassifier.

    Input/output:
    - accepts:
       weka.core.Instances
       weka.core.Instance
    - generates:
       adams.flow.container.WekaModelContainer


    Container information:
    - adams.flow.container.WekaModelContainer: Model, Header, Dataset

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
        min-user-mode: Expert
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: WekaTrainClassifier
     
    -annotation <adams.core.base.BaseAnnotation> (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 execution at this level gets stopped in case this
        actor encounters an error; the error gets propagated; useful for critical
        actors.
        default: false
        min-user-mode: Expert
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console; Note: the enclosing
        actor handler must have this enabled as well.
        default: false
        min-user-mode: Expert
     
    -classifier <adams.flow.core.CallableActorReference> (property: classifier)
        The Weka classifier to train on the input data.
        default: WekaClassifierSetup
     
    -skip-build <boolean> (property: skipBuild)
        If enabled, the buildClassifier call gets skipped in case of incremental
        classifiers, eg, if the model only needs updating after being loaded from
        disk.
        default: false
     
    -prefer-jobrunner <boolean> (property: preferJobRunner)
        If enabled, tries to offload the processing onto a adams.flow.standalone.JobRunnerInstance.
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_INCREMENTALCLASSIFIER

        public static final String BACKUP_INCREMENTALCLASSIFIER
        the key for storing the current incremental classifier in the backup.
        See Also:
        Constant Field Values
      • m_IncrementalClassifier

        protected weka.classifiers.Classifier m_IncrementalClassifier
        the classifier to use when training incrementally.
      • m_SkipBuild

        protected boolean m_SkipBuild
        whether to skip the buildClassifier call for incremental classifiers.
      • m_PreferJobRunner

        protected boolean m_PreferJobRunner
        whether to offload training into a JobRunnerInstance.
      • m_JobRunnerInstance

        protected transient JobRunnerInstance m_JobRunnerInstance
        the JobRunnerInstance to use.
    • Constructor Detail

      • WekaTrainClassifier

        public WekaTrainClassifier()
    • Method Detail

      • setClassifier

        public void setClassifier​(CallableActorReference value)
        Sets the name of the callable classifier to use.
        Parameters:
        value - the name
      • getClassifier

        public CallableActorReference getClassifier()
        Returns the name of the callable classifier in use.
        Returns:
        the name
      • classifierTipText

        public String classifierTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSkipBuild

        public void setSkipBuild​(boolean value)
        Sets whether to skip the buildClassifier call for incremental classifiers.
        Parameters:
        value - true if to skip the buildClassifier call
      • getSkipBuild

        public boolean getSkipBuild()
        Returns whether to skip the buildClassifier call for incremental classifiers.
        Returns:
        true if to skip buildClassifier
      • skipBuildTipText

        public String skipBuildTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPreferJobRunner

        public void setPreferJobRunner​(boolean value)
        Sets whether to offload processing to a JobRunner instance if available.
        Specified by:
        setPreferJobRunner in interface JobRunnerSupporter
        Parameters:
        value - if true try to find/use a JobRunner instance
      • getPreferJobRunner

        public boolean getPreferJobRunner()
        Returns whether to offload processing to a JobRunner instance if available.
        Specified by:
        getPreferJobRunner in interface JobRunnerSupporter
        Returns:
        if true try to find/use a JobRunner instance
      • preferJobRunnerTipText

        public String preferJobRunnerTipText()
        Returns the tip text for this property.
        Specified by:
        preferJobRunnerTipText in interface JobRunnerSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class AbstractActor
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        weka.core.Instances.class, weka.core.Instance.class
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        adams.flow.container.WekaModelContainer.class
      • getClassifierInstance

        protected weka.classifiers.Classifier getClassifierInstance()
                                                             throws Exception
        Returns an instance of the callable classifier.
        Returns:
        the classifier
        Throws:
        Exception - if fails to obtain classifier
      • doExecute

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