Class WekaCrossValidationSplit

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

    public class WekaCrossValidationSplit
    extends AbstractTransformer
    implements Randomizable, InstancesViewCreator
    Generates train/test pairs like during a cross-validation run. It is possible to generate pairs for leave-one-out cross-validation (LOOCV) as well.
    It is essential that a class attribute is set. In case of a nominal class attribute, the data gets stratified automatically.
    Each of the pairs gets forwarded as a container. The training set can be accessed in the container with 'Train' and the test set with 'Test'.

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


    Container information:
    - adams.flow.container.WekaTrainTestSetContainer: Train, Test, Seed, FoldNumber, FoldCount, Train original indices, Test original indices

    -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: WekaCrossValidationSplit
     
    -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
     
    -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
     
    -seed <long> (property: seed)
        The seed value for the randomization.
        default: 1
     
    -folds <int> (property: folds)
        The folds to use; using '-1' will generate folds for leave-one-out cross-validation 
        (LOOCV).
        default: 10
     
    -relation <java.lang.String> (property: relationName)
        The placeholders for creating the relation name: @ = original relation name,
         $T = type (train/test), $N = current fold number.
        default: @
     
    -create-view <boolean> (property: createView)
        If enabled, views of the dataset are created instead of actual copies.
        default: false
     
    -generator <weka.classifiers.CrossValidationFoldGenerator> (property: generator)
        The scheme to use for generating the folds; the actor options take precedence
        over the scheme's ones.
        default: weka.classifiers.DefaultCrossValidationFoldGenerator
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_GENERATOR

        public static final String BACKUP_GENERATOR
        the key for storing the current fold in the backup.
        See Also:
        Constant Field Values
      • m_Seed

        protected long m_Seed
        the seed value.
      • m_Folds

        protected int m_Folds
        the number of folds to generate.
      • m_RelationName

        protected String m_RelationName
        the format of the relation names of the generated datasets.
      • m_CreateView

        protected boolean m_CreateView
        whether to create a view only.
    • Constructor Detail

      • WekaCrossValidationSplit

        public WekaCrossValidationSplit()
    • Method Detail

      • accepts

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

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        adams.flow.container.WekaTrainTestSetContainer.class
      • 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, use -1 for LOOCV
      • getFolds

        public int getFolds()
        Returns the number of folds to generate.
        Returns:
        the folds, 1 in case of LOOCV
      • 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.
      • setRelationName

        public void setRelationName​(String value)
        Sets the pattern to use for renaming the relation.
        Parameters:
        value - the pattern
      • getRelationName

        public String getRelationName()
        Returns the pattern used for renaming the relation.
        Returns:
        the pattern
      • relationNameTipText

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

        public void setCreateView​(boolean value)
        Sets whether to create a view only.
        Specified by:
        setCreateView in interface InstancesViewCreator
        Parameters:
        value - true if to create a view only
      • getCreateView

        public boolean getCreateView()
        Returns whether to create only a view.
        Specified by:
        getCreateView in interface InstancesViewCreator
        Returns:
        true if to create view only
      • createViewTipText

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

        public void setGenerator​(CrossValidationFoldGenerator value)
        Sets the scheme for generating the folds.
        Parameters:
        value - the generator
      • generatorTipText

        public String generatorTipText()
        Returns the tip text for this property.
        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
      • doExecute

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