Class RonWeasley

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.Pausable, adams.core.Randomizable, adams.core.ShallowCopySupporter<adams.opt.genetic.AbstractGeneticAlgorithm>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.core.ThreadLimiter, adams.event.GeneticFitnessChangeNotifier, Serializable

    public class RonWeasley
    extends adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm
    Ron Weasley.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -num-threads <int> (property: numThreads)
        The number of threads to use for executing the jobs; use -1 for all available 
        cores.
        default: -1
        minimum: -1
     
    -num-chrom <int> (property: numChrom)
        The number of chromosomes, ie, the population size.
        default: 50
     
    -stopping-criterion <adams.genetic.stopping.AbstractStoppingCriterion> (property: stoppingCriterion)
        The stopping criterion to use.
        default: adams.genetic.stopping.MaxIterations
     
    -seed <long> (property: seed)
        The seed value for the random number generator.
        default: 1
     
    -initial-weights <java.lang.String> (property: initialWeights)
        The initial weights to use, rather than random ones (string of 0s and 1s
        ).
        default: 
     
    -favor-zeroes <boolean> (property: favorZeroes)
        Whether to favor 0s instead of 1s.
        default: false
     
    -best <java.lang.String> (property: bestRange)
        The range of the best attributes.
        default: -none-
     
    -notify <int> (property: notificationInterval)
        The time interval in seconds after which notification events about changes 
        in the fitness can be sent (-1 = never send notifications; 0 = whenever 
        a change occurs).
        default: -1
     
    -bits-per-gene <int> (property: bitsPerGene)
        The number of bits per gene to use.
        default: 1
        minimum: 1
     
    -class <adams.data.weka.WekaAttributeIndex> (property: classIndex)
        The class index of the dataset, in case no class attribute is set.
        default: last
        example: An index is a number starting with 1; apart from attribute names (case-sensitive), the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -folds <int> (property: folds)
        The number of folds to use in cross-validation.
        default: 10
        minimum: 2
     
    -cv-seed <int> (property: crossValidationSeed)
        The seed value for cross-validation.
        default: 55
     
    -classifier <weka.classifiers.Classifier> (property: classifier)
        The classifier to use.
        default: weka.classifiers.rules.ZeroR
     
    -measure <CC|RMSE|RRSE|MAE|RAE|ACC> (property: measure)
        The measure used for evaluating the fitness.
        default: RMSE
     
    -output-dir <adams.core.io.PlaceholderDirectory> (property: outputDirectory)
        The directory for storing the generated ARFF files.
        default: ${CWD}
     
    -output-type <NONE|SETUP|DATA|ALL> (property: outputType)
        The type of output to generate.
        default: ALL
     
    -output-prefix-type <NONE|RELATION|SUPPLIED> (property: outputPrefixType)
        The type of prefix to use for the output.
        default: NONE
     
    -supplied-prefix <java.lang.String> (property: suppliedPrefix)
        The prefix to use in case of SUPPLIED.
        default: 
     
    -segments <int> (property: segments)
        The number of segments to split into for s-g.
        default: 4
     
    -minPLS <int> (property: minPLS)
        The min number of pls componenents.
        default: 16
     
    -maxPLS <int> (property: maxPLS)
        The max number of pls componenents.
        default: 32
     
    -minSG <int> (property: minSG)
        The min sg smoothing window.
        default: 4
     
    -maxSG <int> (property: maxSG)
        The max sg smoothing window.
        default: 64
     
    Version:
    $Revision: 4322 $
    Author:
    Dale (dale at cs dot waikato dot ac dot nz), FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RonWeasley.RonWeasleyJob
      A job class specific to Ron Weasley.
      • Nested classes/interfaces inherited from class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm

        adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm.ClassifierBasedGeneticAlgorithmJob<T extends adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm>
      • Nested classes/interfaces inherited from class adams.opt.genetic.AbstractGeneticAlgorithm

        adams.opt.genetic.AbstractGeneticAlgorithm.FitnessContainer, adams.opt.genetic.AbstractGeneticAlgorithm.GeneticAlgorithmJob<T extends adams.opt.genetic.AbstractGeneticAlgorithm>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int len  
      protected int m_maxPLSComponents  
      protected int m_maxSG  
      protected int m_minPLSComponents  
      protected int m_minSG  
      protected int m_numSegments  
      protected int numatts  
      • Fields inherited from class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm

        m_BitsPerGene, m_Classifier, m_ClassIndex, m_ClassLabelIndex, m_CrossValidationSeed, m_EvaluationPostProcessor, m_FlowContext, m_Folds, m_Generator, m_Instances, m_JobRunner, m_JobRunnerSetup, m_Measure, m_OutputDirectory, m_OutputPrefixType, m_OutputType, m_SetupUpload, m_StoredResults, m_SuppliedPrefix, m_TestInstances, PROPS_FILTER, PROPS_MASK, PROPS_RELATION
      • Fields inherited from class adams.opt.genetic.AbstractGeneticAlgorithm

        m_ActualNumChrom, m_BestFitness, m_BestRange, m_BestSetup, m_BestWeights, m_CurrentIteration, m_FavorZeroes, m_Fitness, m_FitnessChangeListeners, m_FitnessHistory, m_Genes, m_InitialSetupsProvider, m_InitialWeights, m_LastNotificationTime, m_MaxFitnessHistorySize, m_NotificationInterval, m_NumChrom, m_NumGenes, m_NumThreads, m_Paused, m_Random, m_Running, m_Seed, m_Stopped, m_StoppingCriterion
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Constructor Summary

      Constructors 
      Constructor Description
      RonWeasley()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void defineOptions()
      Adds options to the internal list of options.
      protected adams.opt.genetic.OutputType getDefaultOutputType()
      Returns the default output type to use.
      protected int getInt​(int start, int length, int[] c)  
      int getMaxPLS()
      Get max PLS components
      int getMaxSG()
      Get max sg smoothing windows
      int getMinPLS()
      Get minimum pls components
      int getMinSG()
      Get minimum sg
      protected int getNumSegments()  
      protected int getPLSBits()  
      protected int getPLSComponentFromWeights​(int[] w)  
      int getSegments()
      Get number of s-g segments
      protected int getSGBits()  
      int getSGFromWeights​(int segment, int[] w)  
      String globalInfo()
      Returns a string describing the object.
      String maxPLSTipText()
      Returns the tip text for this property.
      String maxSGTipText()
      Returns the tip text for this property.
      String minPLSTipText()
      Returns the tip text for this property.
      String minSGTipText()
      Returns the tip text for this property.
      protected RonWeasley.RonWeasleyJob newJob​(int chromosome, int[] w, weka.core.Instances data, weka.core.Instances testData)
      Creates a new Job instance.
      protected void preRun()
      Some more initializations.
      String segmentsTipText()
      Returns the tip text for this property.
      void setMaxPLS​(int max)
      Set max pls components
      void setMaxSG​(int sg)
      Set max sg smoothing window
      void setMinPLS​(int pls)
      Set minimum pls components
      void setMinSG​(int sg)
      Set minimum sg
      void setSegments​(int seg)
      Set number of s-g segments to optimise
      protected adams.core.Properties storeSetup​(weka.core.Instances data, adams.opt.genetic.AbstractGeneticAlgorithm.GeneticAlgorithmJob job)
      Generates a Properties file that stores information on the setup of the genetic algorithm.
      • Methods inherited from class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm

        addResult, bitsPerGeneTipText, calcFitness, classifierTipText, classIndexTipText, classLabelIndexTipText, clearResults, crossValidationSeedTipText, evaluationPostProcessorTipText, foldsTipText, generatorTipText, getBitsPerGene, getClassifier, getClassIndex, getClassLabelIndex, getCrossValidationSeed, getCurrentFitness, getDefaultClassifier, getEvaluationPostProcessor, getFlowContext, getFolds, getGenerator, getInstances, getJobRunnerSetup, getMeasure, getOutputDirectory, getOutputPrefixType, getOutputType, getResult, getSetupUpload, getSuppliedPrefix, getTestInstances, measureTipText, outputDirectoryTipText, outputPrefixTypeTipText, outputTypeTipText, postRun, setBitsPerGene, setClassifier, setClassIndex, setClassLabelIndex, setCrossValidationSeed, setEvaluationPostProcessor, setFlowContext, setFolds, setGenerator, setInstances, setJobRunnerSetup, setMeasure, setOutputDirectory, setOutputPrefixType, setOutputType, setSetupUpload, setSuppliedPrefix, setTestInstances, setupUploadTipText, stopExecution, suppliedPrefixTipText, toString, updateHeader
      • Methods inherited from class adams.opt.genetic.AbstractGeneticAlgorithm

        addFitnessChangeListener, addToFitnessHistory, bestRangeTipText, copyGene, doCrossovers, doMutations, doMutations2, favorZeroesTipText, forCommandLine, forName, getBestRange, getCurrentIteration, getCurrentSetup, getCurrentWeights, getDefaultInitialSetupsProvider, getFavorZeroes, getFitness, getFitnessHistory, getGene, getGeneticAlgorithms, getInitialSetups, getInitialSetupsProvider, getInitialWeights, getMaxFitnessHistorySize, getNotificationInterval, getNumChrom, getNumGenes, getNumThreads, getSeed, getStoppingCriterion, hasMoreZeroes, init, initialize, initialSetupsProviderTipText, initialWeightsTipText, isBetterFitness, isPaused, isRunning, isStopped, logChromosomes, maxFitnessHistorySizeTipText, notificationIntervalTipText, notifyFitnessChangeListeners, notifyFitnessChangeListeners, numChromTipText, numThreadsTipText, pauseExecution, removeFitnessChangeListener, reset, resumeExecution, run, runGeneticAlgorithm, seedTipText, setBestRange, setBestRange, setFavorZeroes, setGene, setGene, setInitialSetupsProvider, setInitialWeights, setMaxFitnessHistorySize, setNewFitness, setNotificationInterval, setNumChrom, setNumThreads, setSeed, setStoppingCriterion, shallowCopy, shallowCopy, sort, stoppingCriterionTipText
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.event.GeneticFitnessChangeNotifier

        addFitnessChangeListener, removeFitnessChangeListener
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Field Detail

      • m_numSegments

        protected int m_numSegments
      • m_minPLSComponents

        protected int m_minPLSComponents
      • m_maxPLSComponents

        protected int m_maxPLSComponents
      • m_minSG

        protected int m_minSG
      • m_maxSG

        protected int m_maxSG
      • len

        protected int len
      • numatts

        protected int numatts
    • Constructor Detail

      • RonWeasley

        public RonWeasley()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm
      • getDefaultOutputType

        protected adams.opt.genetic.OutputType getDefaultOutputType()
        Returns the default output type to use.
        Specified by:
        getDefaultOutputType in class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm
        Returns:
        the type
      • setSegments

        public void setSegments​(int seg)
        Set number of s-g segments to optimise
        Parameters:
        seg -
      • getSegments

        public int getSegments()
        Get number of s-g segments
        Returns:
        segments
      • segmentsTipText

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

        public int getMinPLS()
        Get minimum pls components
        Returns:
        min pls components
      • setMinPLS

        public void setMinPLS​(int pls)
        Set minimum pls components
        Parameters:
        pls - min comps
      • minPLSTipText

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

        public void setMaxPLS​(int max)
        Set max pls components
        Parameters:
        max - pls comps.
      • getMaxPLS

        public int getMaxPLS()
        Get max PLS components
        Returns:
        max comps
      • maxPLSTipText

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

        public void setMinSG​(int sg)
        Set minimum sg
        Parameters:
        sg -
      • getMinSG

        public int getMinSG()
        Get minimum sg
        Returns:
        min sg window
      • minSGTipText

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

        public int getMaxSG()
        Get max sg smoothing windows
        Returns:
        sg window max
      • setMaxSG

        public void setMaxSG​(int sg)
        Set max sg smoothing window
        Parameters:
        sg - window maxs
      • maxSGTipText

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

        protected int getPLSBits()
      • getSGBits

        protected int getSGBits()
      • getInt

        protected int getInt​(int start,
                             int length,
                             int[] c)
      • getPLSComponentFromWeights

        protected int getPLSComponentFromWeights​(int[] w)
      • getNumSegments

        protected int getNumSegments()
      • getSGFromWeights

        public int getSGFromWeights​(int segment,
                                    int[] w)
      • newJob

        protected RonWeasley.RonWeasleyJob newJob​(int chromosome,
                                                  int[] w,
                                                  weka.core.Instances data,
                                                  weka.core.Instances testData)
        Creates a new Job instance.
        Specified by:
        newJob in class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm
        Parameters:
        chromosome - the number of chromosomes
        w - the initial weights
        data - the data to use
        testData - the test data to use, null for cross-validation
        Returns:
        the instance
      • storeSetup

        protected adams.core.Properties storeSetup​(weka.core.Instances data,
                                                   adams.opt.genetic.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.
        Overrides:
        storeSetup in class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm
        Parameters:
        data - the data to create the setup for
        job - the associated job
        Returns:
        the generated setup
        See Also:
        AbstractClassifierBasedGeneticAlgorithm.PROPS_RELATION
      • preRun

        protected void preRun()
        Some more initializations.
        Overrides:
        preRun in class adams.opt.genetic.AbstractClassifierBasedGeneticAlgorithm