Class Hermione

  • 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 Hermione
    extends AbstractClassifierBasedGeneticAlgorithmWithSecondEvaluation
    Hermione.

    -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-setups-provider <adams.genetic.initialsetups.AbstractInitialSetupsProvider> (property: initialSetupsProvider)
        The initial setups provider to use.
        default: adams.genetic.initialsetups.EmptyInitialSetupsProvider
     
    -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; numeric indices can be enforced by preceding them with '#' (eg '#12'); attribute names can be surrounded by double quotes.
     
    -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: SETUP
     
    -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: 
     
    -use-second-evaluation <boolean> (property: useSecondEvaluation)
        If enabled, a second evaluation is performed using the separate folds and 
        seed.
        default: false
     
    -second-folds <int> (property: secondFolds)
        The number of folds to use in cross-validation (second evaluation).
        default: 10
        minimum: 2
     
    -second-cv-seed <int> (property: secondCrossValidationSeed)
        The seed value for cross-validation (second evaluation).
        default: 42
     
    -handler <adams.core.discovery.AbstractGeneticDiscoveryHandler> [-handler ...] (property: handlers)
        The discovery handlers to use.
        default: 
     
    Author:
    Dale (dale at cs dot waikato dot ac dot nz), FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Handlers

        protected adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] m_Handlers
        the handlers to use for discovery.
    • Constructor Detail

      • Hermione

        public Hermione()
    • 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
      • setHandlers

        public void setHandlers​(adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] value)
        Sets the discovery handlers to use.
        Parameters:
        value - the classifier
      • getHandlers

        public adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] getHandlers()
        Returns the currently set discovery handlers.
        Returns:
        the handlers
      • handlersTipText

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

        protected Hermione.HermioneJob newJob​(int chromosome,
                                              int[] w,
                                              weka.core.Instances data,
                                              weka.core.Instances testData)
        Creates a new Job instance.
        Specified by:
        newJob in class 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
      • stringToIntArray

        public int[] stringToIntArray​(String s)
        Converts the bit string into an int array.
        Parameters:
        s - the string to convert
        Returns:
        the bit array
      • intArrayToString

        public String intArrayToString​(int[] ia)
        Int array of bits to string.
        Parameters:
        ia - the int array
        Returns:
        the generated bit string
      • setBitsForPosition

        public void setBitsForPosition​(int chromosome,
                                       int[] weights,
                                       List<Integer> starts,
                                       List<Integer> numbits,
                                       int pos,
                                       int[] newWeights)
        Updates the bits.
        Parameters:
        chromosome - the chromosome this is for
        weights - the overall weights
        starts - the starting points
        numbits - the number of bits
        pos - the position
        newWeights - the new weights to set
      • getBitsForPosition

        public int[] getBitsForPosition​(int[] weights,
                                        List<Integer> starts,
                                        List<Integer> numbits,
                                        int pos)
        get bit array for parameter at pos.
        Parameters:
        weights - the overall weights
        starts - the starting points
        numbits - the number of bits
        pos - the position
        Returns:
        the weights subset
      • getNumBitsForAll

        public List<Integer> getNumBitsForAll​(adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] handlers)
        Get List containing number of bits used for params
        Returns:
        the list of number of bits
      • getStartPoints

        public List<Integer> getStartPoints​(adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] handlers)
        Get List of start positions in bit string
        Returns:
        the starting positions
      • getNumBits

        public int getNumBits​(adams.core.discovery.genetic.AbstractGeneticDiscoveryHandler[] handlers)
        Get total number of bits for params
        Returns:
        the total number of bits
      • generateClassifier

        public weka.classifiers.Classifier generateClassifier​(int chromosome,
                                                              int[] weights)
        Generate the classifier from current bit array
        Parameters:
        chromosome - the chromosome index
        weights - the bit array
        Returns:
        the classifier