Class AbstractClassifierBasedGeneticAlgorithm

    • Field Detail

      • PROPS_RELATION

        public static final String PROPS_RELATION
        the key for the relation name in the generated properties file.
        See Also:
        Constant Field Values
      • PROPS_FILTER

        public static final String PROPS_FILTER
        the key for a filter setup in the setup properties.
        See Also:
        Constant Field Values
      • m_Instances

        protected weka.core.Instances m_Instances
        the data to use for cross-validation.
      • m_TestInstances

        protected weka.core.Instances m_TestInstances
        the data to use for evaluation (if null, cross-validation is used).
      • m_BitsPerGene

        protected int m_BitsPerGene
        the bits per gene to use.
      • m_Classifier

        protected weka.classifiers.Classifier m_Classifier
        the classifier to use.
      • m_Folds

        protected int m_Folds
        the number of folds for cross-validation.
      • m_CrossValidationSeed

        protected int m_CrossValidationSeed
        the cross-validation seed.
      • m_Measure

        protected Measure m_Measure
        the measure to use for evaluating the fitness.
      • m_ClassLabelIndex

        protected WekaLabelIndex m_ClassLabelIndex
        the label index.
      • m_OutputDirectory

        protected PlaceholderDirectory m_OutputDirectory
        the directory to store the generated ARFF files in.
      • m_OutputType

        protected OutputType m_OutputType
        the type of output to generate.
      • m_OutputPrefixType

        protected OutputPrefixType m_OutputPrefixType
        the type of prefix to use for the output.
      • m_SuppliedPrefix

        protected String m_SuppliedPrefix
        the supplied prefix.
      • m_JobRunnerSetup

        protected transient JobRunnerSetup m_JobRunnerSetup
        the jobrunner setup.
      • m_FlowContext

        protected Actor m_FlowContext
        the flow context.
    • Constructor Detail

      • AbstractClassifierBasedGeneticAlgorithm

        public AbstractClassifierBasedGeneticAlgorithm()
    • Method Detail

      • setClassIndex

        public void setClassIndex​(WekaAttributeIndex value)
        Sets the class index.
        Parameters:
        value - the class index
      • getClassIndex

        public WekaAttributeIndex getClassIndex()
        Returns the current class index.
        Returns:
        the class index
      • classIndexTipText

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

        public void setInstances​(weka.core.Instances value)
        Sets the data to use for cross-validation.
        Parameters:
        value - the dataset
      • getInstances

        public weka.core.Instances getInstances()
        Returns the currently set dataset for cross-validation.
        Returns:
        the dataset
      • setTestInstances

        public void setTestInstances​(weka.core.Instances value)
        Sets the currently set test set (if null, cross-validation is used).
        Parameters:
        value - the dataset
      • getTestInstances

        public weka.core.Instances getTestInstances()
        Returns the currently set test set (if null, cross-validation is used).
        Returns:
        the dataset
      • setFolds

        public void setFolds​(int value)
        Sets the number of folds to use in cross-validation.
        Parameters:
        value - the number of folds
      • getFolds

        public int getFolds()
        Returns the number of folds to use in cross-validation.
        Returns:
        the number of 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.
      • setCrossValidationSeed

        public void setCrossValidationSeed​(int value)
        Sets the seed value to use for cross-validation.
        Parameters:
        value - the seed to use
      • getCrossValidationSeed

        public int getCrossValidationSeed()
        Returns the current seed value for cross-validation.
        Returns:
        the seed value
      • crossValidationSeedTipText

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

        protected weka.classifiers.Classifier getDefaultClassifier()
        Returns the default classifier to use.
        Returns:
        the classifier
      • setClassifier

        public void setClassifier​(weka.classifiers.Classifier value)
        Sets the classifier to use.
        Parameters:
        value - the classifier
      • getClassifier

        public weka.classifiers.Classifier getClassifier()
        Returns the currently set classifier.
        Returns:
        the classifier
      • 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.
      • setBitsPerGene

        public void setBitsPerGene​(int value)
        Sets the bits per gene to use.
        Parameters:
        value - the number of bits
      • getBitsPerGene

        public int getBitsPerGene()
        Returns the currently set number of bits per gene.
        Returns:
        the number of bits
      • bitsPerGeneTipText

        public String bitsPerGeneTipText()
        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​(Measure value)
        Sets the measure used for evaluating the fitness.
        Parameters:
        value - the fitness measure
      • getMeasure

        public Measure getMeasure()
        Returns the current measure for evaluating the fitness.
        Returns:
        the 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.
      • setClassLabelIndex

        public void setClassLabelIndex​(WekaLabelIndex value)
        Sets the index of the class label to use for statistics that work on a per-label-basis.
        Parameters:
        value - the index
      • getClassLabelIndex

        public WekaLabelIndex getClassLabelIndex()
        Returns the index of the class label to use for statistics that work on a per-label-basis.
        Returns:
        the index
      • classLabelIndexTipText

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

        public void setEvaluationPostProcessor​(AbstractWekaEvaluationPostProcessor value)
        Sets the post-processing scheme for the evaluation.
        Parameters:
        value - the post-processor
      • getEvaluationPostProcessor

        public AbstractWekaEvaluationPostProcessor getEvaluationPostProcessor()
        Returns the post-processing scheme for the evaluation.
        Returns:
        the post-processor
      • evaluationPostProcessorTipText

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

        public void setOutputDirectory​(PlaceholderDirectory value)
        Sets the directory for the generated ARFF files.
        Parameters:
        value - the directory
      • getOutputDirectory

        public PlaceholderDirectory getOutputDirectory()
        Returns the currently set directory for the generated ARFF files.
        Returns:
        the directory
      • outputDirectoryTipText

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

        protected abstract OutputType getDefaultOutputType()
        Returns the default output type to use.
        Returns:
        the type
      • setOutputType

        public void setOutputType​(OutputType value)
        Sets the type of output to generate.
        Parameters:
        value - the type
      • getOutputType

        public OutputType getOutputType()
        Returns the type of output to generate.
        Returns:
        the type
      • outputTypeTipText

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

        public void setOutputPrefixType​(OutputPrefixType value)
        Sets the type of prefix to use for the output.
        Parameters:
        value - the type
      • getOutputPrefixType

        public OutputPrefixType getOutputPrefixType()
        Returns the type of prefix to use for the output.
        Returns:
        the type
      • outputPrefixTypeTipText

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

        public void setSuppliedPrefix​(String value)
        Sets the prefix to use in case of OutputPrefixType.SUPPLIED.
        Parameters:
        value - the prefix
      • suppliedPrefixTipText

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

        public void setSetupUpload​(AbstractSetupUpload value)
        Sets the scheme for uploading the currently best job setup.
        Parameters:
        value - the upload scheme
      • getSetupUpload

        public AbstractSetupUpload getSetupUpload()
        Returns the scheme for uploading the currently best job setup.
        Returns:
        the upload scheme
      • setupUploadTipText

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

        public void setJobRunnerSetup​(JobRunnerSetup value)
        Sets the jobrunner setup to use.
        Parameters:
        value - the setup, can be null to use default
      • getJobRunnerSetup

        public JobRunnerSetup getJobRunnerSetup()
        Returns the jobrunner setup in use.
        Returns:
        the setup, null if using default
      • setFlowContext

        public void setFlowContext​(Actor value)
        Sets the flow context, if any.
        Parameters:
        value - the context
      • getFlowContext

        public Actor getFlowContext()
        Return the flow context, if any.
        Returns:
        the context, null if none available
      • storeSetup

        protected Properties storeSetup​(weka.core.Instances data,
                                        AbstractGeneticAlgorithm.GeneticAlgorithmJob job)
        Generates a Properties file that stores information on the setup of the genetic algorithm. E.g., it backs up the original relation name. The generated properties file will be used as new relation name for the data. Derived classes can add additional parameters to this properties file.
        Parameters:
        data - the data to create the setup for
        job - the associated job
        Returns:
        the generated setup
        See Also:
        PROPS_RELATION
      • updateHeader

        public weka.core.Instances updateHeader​(weka.core.Instances data,
                                                AbstractGeneticAlgorithm.GeneticAlgorithmJob job)
        Creates a new dataset, with the setup as the new relation name.
        Parameters:
        data - the data to replace the relation name with the setup
        job - the associated job
        Returns:
        the updated dataset
      • addResult

        protected void addResult​(String key,
                                 Double val)
        Adds a result to the cache.
        Parameters:
        key - the key of the result
        val - the value to add
      • getResult

        protected Double getResult​(String key)
        Returns a value from the cache.
        Parameters:
        key - the key of the result
        Returns:
        the result or null if not present
      • clearResults

        protected void clearResults()
        Clears all currently stored results.
      • newJob

        protected abstract AbstractClassifierBasedGeneticAlgorithm.ClassifierBasedGeneticAlgorithmJob newJob​(int chromosome,
                                                                                                             int[] w,
                                                                                                             weka.core.Instances data,
                                                                                                             weka.core.Instances testData)
        Creates a new Job instance.
        Parameters:
        chromosome - the chromosome index
        w - the initial weights
        data - the data to use
        testData - the test data to use, null for cross-validation
        Returns:
        the instance
      • toString

        public String toString()
        Returns a short string of the algorithm with the currently best fitness.
        Overrides:
        toString in class AbstractOptionHandler
        Returns:
        a short info string