Package weka.attributeSelection
Class GeneticSearch
- java.lang.Object
-
- weka.attributeSelection.ASSearch
-
- weka.attributeSelection.GeneticSearch
-
- All Implemented Interfaces:
java.io.Serializable,StartSetHandler,OptionHandler,RevisionHandler,TechnicalInformationHandler
public class GeneticSearch extends ASSearch implements StartSetHandler, OptionHandler, TechnicalInformationHandler
GeneticSearch:
Performs a search using the simple genetic algorithm described in Goldberg (1989).
For more information see:
David E. Goldberg (1989). Genetic algorithms in search, optimization and machine learning. Addison-Wesley. BibTeX:@book{Goldberg1989, author = {David E. Goldberg}, publisher = {Addison-Wesley}, title = {Genetic algorithms in search, optimization and machine learning}, year = {1989}, ISBN = {0201157675} }Valid options are:-P <start set> Specify a starting set of attributes. Eg. 1,3,5-7.If supplied, the starting set becomes one member of the initial random population.
-Z <population size> Set the size of the population (even number). (default = 20).
-G <number of generations> Set the number of generations. (default = 20)
-C <probability of crossover> Set the probability of crossover. (default = 0.6)
-M <probability of mutation> Set the probability of mutation. (default = 0.033)
-R <report frequency> Set frequency of generation reports. e.g, setting the value to 5 will report every 5th generation (default = number of generations)
-S <seed> Set the random number seed. (default = 1)
- Version:
- $Revision: 6759 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GeneticSearch()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcrossoverProbTipText()Returns the tip text for this propertydoublegetCrossoverProb()get the probability of crossoverintgetMaxGenerations()get the number of generationsdoublegetMutationProb()get the probability of mutationjava.lang.String[]getOptions()Gets the current settings of ReliefFAttributeEval.intgetPopulationSize()get the size of the populationintgetReportFrequency()get how often repports are generatedjava.lang.StringgetRevision()Returns the revision string.intgetSeed()get the value of the random number generator's seedjava.lang.StringgetStartSet()Returns a list of attributes (and or attribute ranges) as a StringTechnicalInformationgetTechnicalInformation()Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.java.lang.StringglobalInfo()Returns a string describing this search methodjava.util.EnumerationlistOptions()Returns an enumeration describing the available options.java.lang.StringmaxGenerationsTipText()Returns the tip text for this propertyjava.lang.StringmutationProbTipText()Returns the tip text for this propertyjava.lang.StringpopulationSizeTipText()Returns the tip text for this propertyjava.lang.StringreportFrequencyTipText()Returns the tip text for this propertyint[]search(ASEvaluation ASEval, Instances data)Searches the attribute subset space using a genetic algorithm.java.lang.StringseedTipText()Returns the tip text for this propertyvoidsetCrossoverProb(double c)set the probability of crossovervoidsetMaxGenerations(int m)set the number of generations to evaluatevoidsetMutationProb(double m)set the probability of mutationvoidsetOptions(java.lang.String[] options)Parses a given list of options.voidsetPopulationSize(int p)set the population sizevoidsetReportFrequency(int f)set how often reports are generatedvoidsetSeed(int s)set the seed for random number generationvoidsetStartSet(java.lang.String startSet)Sets a starting set of attributes for the search.java.lang.StringstartSetTipText()Returns the tip text for this propertyjava.lang.StringtoString()returns a description of the search-
Methods inherited from class weka.attributeSelection.ASSearch
forName, makeCopies
-
-
-
-
Method Detail
-
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options. Valid options are:-P <start set> Specify a starting set of attributes. Eg. 1,3,5-7.If supplied, the starting set becomes one member of the initial random population.
-Z <population size> Set the size of the population (even number). (default = 20).
-G <number of generations> Set the number of generations. (default = 20)
-C <probability of crossover> Set the probability of crossover. (default = 0.6)
-M <probability of mutation> Set the probability of mutation. (default = 0.033)
-R <report frequency> Set frequency of generation reports. e.g, setting the value to 5 will report every 5th generation (default = number of generations)
-S <seed> Set the random number seed. (default = 1)
- Specified by:
setOptionsin interfaceOptionHandler- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of ReliefFAttributeEval.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- an array of strings suitable for passing to setOptions()
-
startSetTipText
public java.lang.String startSetTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setStartSet
public void setStartSet(java.lang.String startSet) throws java.lang.ExceptionSets a starting set of attributes for the search. It is the search method's responsibility to report this start set (if any) in its toString() method.- Specified by:
setStartSetin interfaceStartSetHandler- Parameters:
startSet- a string containing a list of attributes (and or ranges), eg. 1,2,6,10-15.- Throws:
java.lang.Exception- if start set can't be set.
-
getStartSet
public java.lang.String getStartSet()
Returns a list of attributes (and or attribute ranges) as a String- Specified by:
getStartSetin interfaceStartSetHandler- Returns:
- a list of attributes (and or attribute ranges)
-
seedTipText
public java.lang.String seedTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSeed
public void setSeed(int s)
set the seed for random number generation- Parameters:
s- seed value
-
getSeed
public int getSeed()
get the value of the random number generator's seed- Returns:
- the seed for random number generation
-
reportFrequencyTipText
public java.lang.String reportFrequencyTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setReportFrequency
public void setReportFrequency(int f)
set how often reports are generated- Parameters:
f- generate reports every f generations
-
getReportFrequency
public int getReportFrequency()
get how often repports are generated- Returns:
- how often reports are generated
-
mutationProbTipText
public java.lang.String mutationProbTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMutationProb
public void setMutationProb(double m)
set the probability of mutation- Parameters:
m- the probability for mutation occuring
-
getMutationProb
public double getMutationProb()
get the probability of mutation- Returns:
- the probability of mutation occuring
-
crossoverProbTipText
public java.lang.String crossoverProbTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCrossoverProb
public void setCrossoverProb(double c)
set the probability of crossover- Parameters:
c- the probability that two population members will exchange genetic material
-
getCrossoverProb
public double getCrossoverProb()
get the probability of crossover- Returns:
- the probability of crossover
-
maxGenerationsTipText
public java.lang.String maxGenerationsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMaxGenerations
public void setMaxGenerations(int m)
set the number of generations to evaluate- Parameters:
m- the number of generations
-
getMaxGenerations
public int getMaxGenerations()
get the number of generations- Returns:
- the maximum number of generations
-
populationSizeTipText
public java.lang.String populationSizeTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setPopulationSize
public void setPopulationSize(int p)
set the population size- Parameters:
p- the size of the population
-
getPopulationSize
public int getPopulationSize()
get the size of the population- Returns:
- the population size
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this search method- Returns:
- a description of the search suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
toString
public java.lang.String toString()
returns a description of the search- Overrides:
toStringin classjava.lang.Object- Returns:
- a description of the search as a String
-
search
public int[] search(ASEvaluation ASEval, Instances data) throws java.lang.Exception
Searches the attribute subset space using a genetic algorithm.
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classASSearch- Returns:
- the revision
-
-